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 > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > assign a value

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-10-06, 11:29
markjason markjason is offline
Registered User
 
Join Date: Jun 2004
Posts: 46
assign a value

I have to assign a result of a query to a vairable like this

how can i do this

Query = select count(*) from table
x=`db2 ${Query}| sed -n '4p'`

but this doesn't work, is there any other way to assign the result without redirecting the result to temp file. .

Thanks
Mark.
Reply With Quote
  #2 (permalink)  
Old 10-10-06, 13:58
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Maybe you need to use "quotes":
Code:
$ cat q0
#!/bin/ksh
. /db2/bin/db2_env.ksh
Query='select count(*) from db2_tablespaces'
x=`db2 "${Query}"|sed -n '4p'`
echo "Result is: $x"
exit
$ q0
Result is:       7
$


__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 10-10-06, 14:07
markjason markjason is offline
Registered User
 
Join Date: Jun 2004
Posts: 46
Thanks, But still i am not getting value to x.

if direct the result to a file and then print the result it is working otherwise
i am getting following error.

result is : SQL30082N Attempt to establish connection failed with security reason "3"
Reply With Quote
  #4 (permalink)  
Old 10-10-06, 15:36
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool




Security reason 3 is: PASSWORD MISSING (The request did not include a password)

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
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