0

i have a program that must fetch information from database & after performing required commands in unix ,o/p must updated back the to database.here fetching information from 3 tables & output must be updated to one table as soon as i get the output for each loop.

    `#{Here the loop must run untill i get values from table}
     x=0 
     while [ $x = '0' ]
      do
      x=`sqlplus -s username/pswd@server << EOF
     set head off
      select min(col1),max(col1) from table
      /
       EOF`
     echo $x|read a b
   x=$a+$b
 done
         #{here functions based on a & b value }
         #{below to update table}
         sqlplus -s username/pswd@server<< EOF
         update table2 set col3 where ..
          commit;

      #similar while loop

     y=0 
     while [ $y = '0' ]
    do
      x=`sqlplus -s username/pswd@server << EOF
   set head off
       select min(col1),max(col1) from table3
    /
       EOF`
       .
       .
jenny
  • 3
  • 2

1 Answers1

1

You could put each loop in a function and then call these functions in background
function loop1
{...}
function loop2
{...}
function loop3
{...}
loop1 &
loop2 &
loop3 &

  • using & ,will function 2 start after function 1 completion?? or 3 functions will start at a time. i'm confused .Please clarify – jenny Jan 31 '15 at 18:57
  • Using & means that execution will not wait for function 1 to complete but will kick it off in background and move to next statement i.e. function 2 call. – Potter_nsit Jan 31 '15 at 19:37
  • After loop3 &, you can add "wait" to have the script wait until all three have completed. Then it will continue on. – pedz Feb 01 '15 at 13:41