Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    106

    Unanswered: bash - udb scripting error check help

    Server: UDB 8.1 solaris server
    Client: Windows xp with bash installed

    I am trying a simple test like this..

    #!/bin/bash

    Echo off

    #
    # Connect to DB2
    #

    db2 connect to sample user db2admin using db2admin

    db2 -x 'call x_validation_list(?)';

    echo $?

    if [ $? -ne 0 ]
    then
    echo "*** stored procedure x_validation_list bad call"
    return
    fi

    echo "the end..."

    db2 connect reset

    RESULTS
    ======
    Got the following message at c prompt:

    Echo: not found

    Database Connection Information

    Database server = DB2/NT 8.1.6
    SQL authorization ID = DB2ADMIN
    Local database alias = STGD01

    SQL0440N No authorization routine named "X_VALIDATION_LIST" of type "PROCEDURE" having compatible arguments was found. SQLSTATE=42884
    4
    the end...
    DB20000I The SQL command completed successfully

    BEHAVIOUR EXPECTED
    =================
    I was expecting results something like this...

    Echo: not found

    Database Connection Information

    Database server = DB2/NT 8.1.6
    SQL authorization ID = DB2ADMIN
    Local database alias = STGD01

    SQL0440N No authorization routine named "X_VALIDATION_LIST" of type "PROCEDURE" having compatible arguments was found. SQLSTATE=42884
    4
    *** stored procedure x_validation_list bad call
    ------------------------------------------------------------

    Can somebody tell me why:
    1. The if coniditon echo is not being displayed - Echo ? did display 4 which is non zero
    2. And the second is really corollary to the above - why did the return not work
    3. RETURN in bash will prevent any statements below it to be executed - Is my understanding right?

    Now the SP x_validation_list is a non-existing SP; So I was hoping that the echo "*** stored procedure x_validation_list bad call" will be displayed and RETURN will stop the script and get out - meaning I DID NOT expect echo "the end..." to display.

    Thanks

    You are the creator of your own destiny!

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    What do you think the value of "$?" is at any given point in time?

  3. #3
    Join Date
    Aug 2003
    Posts
    106
    Before the if condition I do display $? and it returns 4 - Have I answered your question??

    You are the creator of your own destiny!

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    So, it is "4" after the "db2 ..." command. What do you think it is after the "echo ..." command?

  5. #5
    Join Date
    Aug 2003
    Posts
    106
    Ok! Got it! Removed Echo and worked like a charm! Thanks N_J :-)

    You are the creator of your own destiny!

Posting Permissions

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