0

I have the result for the query:

SELECT leg_store_wh_code || ',' || rms_location col1 from SKS_CNV_LOCATION_XREF  as

101,101 1,601 202,602 3,603 4,604 207,607 8,608 9,609 10,610 212,612 613,613 14,614 16,616 17,617 18,618 619,619 20,620 21,621 23,623 24,624 85,625 26,626 28,628 29,629 30,630 31,631 32,632 90,633 34,634 635,635 36,636(store_list_result holds this)

I want to use all the values inside the loop. But only the first value is printing.its going to the next values.Can anyone help me

store_list="SELECT leg_store_wh_code || ',' || rms_location col1 from SKS_CNV_LOCATION_XREF ;"
store_list_result=`sqlplus -s $UP <<EOF

   SET FEEDBACK OFF
   SET HEAD OFF
   SET AUTOPRINT OFF
   SET LINESIZE 1000
   SET TAB OFF
   SET ECHO OFF
   SET PAGESIZE 0
   SET TERMOUT OFF
   SET TRIMSPOOL ON

   ${store_list}          
exit
       EOF`
       for i in store_list_result
       do
         LEG_ID=`echo $store_list_result | cut -d',' -f1`
         echo $LEG_ID
         RMS_ID=`echo $store_list_result | cut -d',' -f2 | cut -d' ' -f1`
         echo $RMS_ID

result I got is:

101
101

1 Answer 1

1
for i in store_list_result do LEG_ID=`echo $store_list_result | cut -d',' -f1`

How is it ever supposed to work? You iterating once ($i="store_list_result", not this variable's value), then you using $store_list_result every time (still once, but it's wrong nevertheless). And format your code properly, grave signs are getting eaten.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.