![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| Avoid "++ requires lvalue" Error in Loop Calculation | sandeepb | Shell Programming and Scripting | 3 | 09-24-2007 07:02 AM |
| Unix "at" / "Cron" Command New Problem...Need help | Mohanraj | UNIX for Dummies Questions & Answers | 3 | 01-26-2006 08:08 PM |
| How to combine "find" command in for each loop (tcsh) | umen | Shell Programming and Scripting | 3 | 08-22-2005 04:07 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hello Everyone,
I'm having a wee bit of a problem. I would like to pass a DB2 query to a variable and then using that variable to perform a 'For' loop. For example.... Code:
tempfile1=`db2 -x "select cast(OBJECT_ID as integer) from $temp_table where SEQUENCE_NO = $sequence_no"`
for id in ${tempfile1}
do
statename=`db2 -x "select STATE_NAME from $temp_table where object_id = $id"`
domain_name=`db2 -x "select domain_name from $temp_table where object_id = $id"`
echo "ID = [$id]"
echo "State = [$statename]"
echo "Domain = [$domain_name]"
done
Code:
ID = [5132] State = [State1 State2] Domain = [Domain1 Domain2] ID = [5146] State = [State1] Domain = [Domain1] ID = [5156] State = [State1 State2] Domain = [Domain1 Domain2] ID = [5132] State = [State1 State2] Domain = [Domain1 Domain2] ID = [5156] State = [State1 State2] Domain = [Domain1 Domain2] Code:
ID = [5132] State = [State1] Domain = [Domain1] ID = [5146] State = [State1] Domain = [Domain1] ID = [5156] State = [State1] Domain = [Domain1] ID = [5132] State = [State2] Domain = [Domain2] ID = [5156] State = [State2] Domain = [Domain2] Thanks in advance..... ![]() ![]() ![]() ![]() ![]() |
|
||||
|
Case 5132 gets returned twice by your first select because it's in two rows.
Then in the state select, two states get returned because there are two states associated with 5132. I suggest doing something like.... Code:
db2 -x ..... | while read A B C D do .... done |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|