Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2011
    Posts
    12

    Question Unanswered: How to return value from script and display information

    Dear Sir,

    I want to know how to return 0/-1 from sql to ksh script. My sql need to be called from unix script. Then, some checking will be proceed in sql, and return -1 if checking result is abnormal. Also, I need to display information during checking, but it doesn't work

    My program as below.

    in ksh.
    db2 "set serveroutput on"
    db2 -td/ +o -f test.sql << EOF1 2>&1
    $x1
    EOF1
    if [ $? -eq 0 ]
    then
    echo 'ok'
    else
    echo 'failed'
    fi
    --------

    In sql,
    Begin
    Declare ....

    select count(*) from ....
    call dbms_output.put_line(count);
    if count > 0 then
    return -1
    else
    retrurn 0
    end if
    end
    -------------------

    Please kindly to let me know what wrong of above program. Thanks !

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by amcc38 View Post
    Also, I need to display information during checking, but it doesn't work
    What do you mean by "doesn't work"? Does your SQL script produce the desired output when run alone manually? Consider also posting the actual code, not your interpretation of what is important.

Posting Permissions

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