• 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:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Rocket Software

    Meet digital age demands while maximizing your IT investment.

    Future-proof your mission-critical applications with Rocket® Solutions for IBM® i that keep your business ahead of the curve.

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • 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

    Solarsoft Reports New Implementations of iVP Suite Some Insight Into the iASP and ISV Issue

    Leave a Reply Cancel 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

  • POWERUp 2025 –Your Source For IBM i 7.6 Information
  • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
  • Guru: Creating An SQL Stored Procedure That Returns A Result Set
  • As I See It: At Any Cost
  • IBM i PTF Guide, Volume 27, Number 19
  • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
  • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
  • i-Rays Brings Observability To IBM i Performance Problems
  • Another Non-TR “Technology Refresh” Happens With IBM i TR6
  • IBM i PTF Guide, Volume 27, Number 18

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