Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    74

    Unanswered: Why can't I get the execution result of CLP in Kron Shell?

    My OS is AIX5.1, ksh and DB2 UDB 8.1 for AIX, the following is my screen capture. Why the second echo command print a NULL string?

    db2 "select count(*) from spe.reexecutepoint"

    1
    -----------
    2

    1 record(s) selected.

    $ unset a
    $ db2 "select count(*) from spe.reexecutepoint" | sed -n '4s/[[:blank:]]//gp' | read a
    $ echo $a
    2
    $ unset a
    $ a=`db2 "select count(*) from spe.reexecutepoint" | sed -n '4s/[[:blank:]]//gp'`
    $ echo $a

    $ unset a
    $ a=`db2 connect to dl>/dev/null;db2 "select count(*) from spe.reexecutepoint" | sed -n '4s/[[:blank:]]//gp'`
    $ echo $a
    2
    $

  2. #2
    Join Date
    Nov 2003
    Posts
    1

    You are starting a new shell !

    when you use `command` you are forking a new shell. When you fork a new shell, you need a db2 connect in the new shell.

    This is the same as:

    db2 connect ...
    db2 "select count (*) ...." this command will return a result

    now if you type:
    sh <return> # start a new shell
    db2 "select count(*) ...."

    you will get:
    SQL1024N A database connection does not exists.

    if you type "exit" and get back to previous shell and
    db2 "select count(*) ...."

    you will get a result.

  3. #3
    Join Date
    Jan 2003
    Posts
    74
    Thank you for your replay, I know!

Posting Permissions

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