Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Terre Haute, IN
    Posts
    7

    Question Unanswered: How can I obtain SQLCODE or SQLSTATE in CLP without stored procedure?

    This is on a SUN OS. DB2 version 8.FixPack4.

    I have tried to assign as follows:

    db2 -tvf myfile.sql > myfile.log

    ------------------------------------------
    connect to alias user userid using password;

    Select *
    ..from my.table
    where condition is false;

    !DB2ERROR=$?;

    quit;
    -----------------------------------------

    The SQLCODE should be a -100. I have done application programming and would typically look in SQLCA to see what the error code is.

    What I would like to do is interpret the error code on the fly without creating a stored procedure.

    Thanks in advance.

    Jeff

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Go to the Command Reference manual and check out the Command Line Processor Options in Chapter 2.

    There are various options that you may want to use such as:

    -a display sqlca
    -w display warning messages (no rows returned is +100 and is a warning)
    etc
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Feb 2004
    Location
    Terre Haute, IN
    Posts
    7
    Let me rephrase the question. Displaying the SQLCA was not the problem.

    The problem I have is: How do I get that value into a variable I can use to retry an insert (for example a timeout)?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •