If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Why can't I get the execution result of CLP in Kron Shell?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-04, 23:46
zhouhaiming zhouhaiming is offline
Registered User
 
Join Date: Jan 2003
Posts: 74
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
$
Reply With Quote
  #2 (permalink)  
Old 11-17-04, 10:01
muneers muneers is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 11-17-04, 19:32
zhouhaiming zhouhaiming is offline
Registered User
 
Join Date: Jan 2003
Posts: 74
Thank you for your replay, I know!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On