• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Odds and Ends: The Reader is the Guru

    March 2, 2011 Dear Professional

    The emails I get from you provide a sterling illustration that the readers of this august publication are the true gurus in the world of IBM i. Here are a few contributions that I hope may prove useful to some of you.

    -Ted


    Hey, Ted:

    I’d like to add an important point when renaming the local database. IBM’s own jobs rely on this local database name entry existing. They don’t care if you have deleted it. They will recreate it pretty quickly if it does not have a name entered, so the commands to delete the old and add the new name may have to be run quickly. It is a good idea to pre-type them in a session or put them in a script to get them to run fast enough.

    –Lynne


    Hey, Ted:

    Regarding your article, Avoid an Unnecessary CPYF Error, I think you could have formulated the MONMSG better.

    Your test of message CPF2817 contains an invalid assumption.

    CPYF    FROMFILE(AAA) TOFILE(BBB) MBROPT(*REPLACE)
    MONMSG  MSGID(CPF2817) EXEC(CLRPFM BBB)  /* AAA IS EMPTY */
    

    CPF2817 can have other meanings besides that the “from” file is empty. For example:

    CPYF FROMFILE(unexisting) TOFILE(myFile) MBROPT(*REPLACE)
    
    From-file UNEXISTING in *LIBL not found.
    Copy command ended because of error.
    

    Better would be:

    CPYF    FROMFILE(AAA) TOFILE(BBB) MBROPT(*REPLACE)
    MONMSG  MSGID(CPF2817) CMPDTA(CPF2869)
     EXEC(CLRPFM BBB)  /* AAA IS EMPTY */
    

    –Jan

    Jan is correct, of course. I appreciate his taking the time to point out the error.

    –Ted


    Hey, Ted:

    In his article V6R1 Run SQL Scripts: Print and Save Result Sets, Skip Marchesani wrote about saving the results of an SQL query to Excel and printing. How can I save the results of an SQL command as a new DB2 file?

    –Harold

    In interactive, green-screen SQL (STRSQL), press F13, then option 1, to get the session attributes screen, where you can choose to output to a file.

    For batch, run CREATE TABLE xxx/yyyy AS (SELECT ….) within RUNSQLSTM.

    –Ted


    Hey, Ted:

    You might find this SQL function of interest.

    Along similar lines to your article, it deals with right-aligning a piece of text in a given space (up to 1K).

    –Daz

    Here’s Daz’s function:

    Create Function RAlign
     (InpStr varchar(1024),
      InpPos integer)
     RETURNS varchar(1024)
     LANGUAGE SQL
     DETERMINISTIC
     RETURNS NULL ON NULL INPUT
     NO EXTERNAL ACTION
     SET OPTION OUTPUT=*PRINT, DBGVIEW=*SOURCE
    BEGIN
     DECLARE TmpTxt varchar(1024);
     DECLARE InpLen integer default 0;
     SET InpLen = length(rtrim(InpStr));
     IF InpLen <= InpPos   THEN
       SET TmpTxt = substr(char(' ', 1024),1,InpPos-InpLen)
                 || rtrim(InpStr);
     ELSE
       SET TmpTxt = (substr(InpStr,InpLen - InpPos + 1 , InpPos));
     END IF;
     RETURN TmpTxt;
    END;
    

    I offer RAlign as an alternative to my RADJ function, in case you may prefer it.

    –Ted

    RELATED STORIES

    How To Rename Your Local Database

    Avoid an Unnecessary CPYF Error

    V6R1 Run SQL Scripts: Print and Save Result Sets

    The SPACE Function Takes Up a Lot of Space



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    Sponsored by
    ARCAD Software

    [IBM i Auditing Tool] Discover the Health of Your IBM i Applications in Minutes with ARCAD iCheck-up

    How well do you really know the health of your IBM i applications? Hidden complexity, unused code, and synchronization issues can make maintenance more challenging and slow down modernization efforts.

    What if you could identify these issues in just a few clicks, without installing anything on your IBM i system?

    Meet ARCAD iCheck-up, an auditing tool designed to give IBM i teams a clear, actionable overview of their applications in minutes.

    With iCheck-up, you can:

    • Assess code complexity: Identify complex source files and prioritize refactoring efforts.
    • Detect dead code: Uncover unused code that may be cluttering your applications.
    • Spot synchronization issues: Identify inconsistencies between source files and compiled objects.
    • Track code changes: Explore modification history and better understand your application’s evolution.
    • Generate a shareable report: Get a comprehensive, easy-to-read HTML report with key metrics and insights.

    Fast, simple, and secure. iCheck-up runs from Windows, requires no installation on your IBM i system, and leaves no files or code behind. Your generated report contains metrics only, keeping your source code confidential.

    Whether you’re maintaining existing applications, planning modernization, or looking to improve code quality, iCheck-up helps you make more informed decisions.

    Ready to gain deeper insights into your IBM i applications? Discover ARCAD iCheck-up and take the first step toward better code quality today!

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Sponsored Links

    System i Developer:  Upgrade your skills at the RPG & DB2 Summit in Orlando, March 22-24
    Townsend Security:  Learn how to easily and securely communicate with XML
    Northeast User Groups Conference:  21th Annual Conference, April 11 - 13, Framingham, MA

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    Running Totals in an SQL Query Admin Alert: Corralling i/OS Storage Hogs, Part 1

    Leave a ReplyCancel reply

Volume 11, Number 8 -- March 2, 2011
THIS ISSUE SPONSORED BY:

WorksRight Software
SEQUEL Software
Northeast User Groups Conference

Table of Contents

  • Running Totals in an SQL Query
  • Odds and Ends: The Reader is the Guru
  • Admin Alert: Corralling i/OS Storage Hogs, Part 1

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Fall TRs Expected Next Week At Combined IBM-COMMON Conference
  • GenAI Brings A New Kind Of Agile Computing That Needs Controls Even More
  • IBM i, AI, And The Cost Of “We’ve Always Done It That Way”
  • Infor Says IBM i Customers Are Welcome To Use New AI
  • IBM i PTF Guide, Volume 28, Number 36
  • Help Us Understand The IBM i Marketplace By Taking The Survey
  • IBM Goes GA With Power Autonomous Operations
  • IBM Wheels And Deals To Sell Power Systems, Storage, and Software
  • Guru: When RNF0722 Won’t Let Your Legendary RPG Program Compile
  • A Read-Only MCP Server For Db2 for i

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle