![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix scripting pl help | sree11 | UNIX for Dummies Questions & Answers | 1 | 12-05-2007 11:46 PM |
| UNIX scripting | moe2266 | UNIX for Dummies Questions & Answers | 5 | 08-06-2007 12:41 PM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 09:12 AM |
| Help With Unix Scripting. | hella | UNIX for Dummies Questions & Answers | 1 | 08-04-2003 11:18 AM |
| UNIX Scripting | wolf | UNIX for Dummies Questions & Answers | 7 | 07-31-2001 02:37 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi
can anyone pls help me out in knowing how a array of elements which are fetched from database is passed to the awk program. Something like this #!/bin/sh AMT[]=`sqlplus -s usrname/pswd <<EOD set pagesize 0 feedback off verify off heading off echo on select amount from tablename where condition; EOD` noofrec=`sqlplus -s usrname/pswd <<EOD set pagesize 0 feedback off verify off heading off echo on select count(*) from tablename where condition; EOD` echo "$AMT[]" $noofrec | awk ' BEGIN { new=$1; printf "%d" ,new; //this works fine with 2nd argumnet but dont know how printf the arrays values? } { printf "%d" ,AMT??? }'END |
|
||||
|
awk
Hi, I am not sure why you will process like this, why not spool the sql result to a file and then process the file. This seems easy to release. Here we can treat the spool file as the array, it should be ok for you. Just try it. Code:
sqlplus -s ops\$global/developer@sf2a <<! spool a.txt select exl_name from exchange_list where rownum<=5; (your sql here) spool off ! while read line do what you want to do with the each result. done < a.txt |
|
||||
|
thank you for the idea,
this works fine but my reqiremnt asks for more than one data to be fetched which also works but same needs to be parsed in the awk program. My requirement says of priting the values of each elements one by one to a file that too in a loop. regards Mohima |
|
||||
|
well it would be bit difficult to satisfy a requirement which requires something like this
#!/bin/sh //iam reading the data for amounts from database AMT[]=`sqlplus -s usrname/pswd <<EOD set pagesize 0 feedback off verify off heading off echo on select amount from tablename where condition; EOD` //writing to a file created at a specifed direcotry using a awk program echo "$AMT[]" $noofrec | awk ' BEGIN { new=$1; ------------------------------------------------------------------ //i need to write the contents of the array in the file (which is created at a specified location) in a loop that prints in each line contents of amount AMT[] array(as long as elements are there). ------------------------------------------------------------------ hence my problem is to print the elements in the array one by one in lines which are equivalent to no of elements in the array. for i furthur read this file for processing Iam able to get the contents into the array from db but couldnt print it in the file please need suggestions asap. Regards Mahima -------------------------------------------------------------------- printf "006%d" ,new; //this works fine with 2nd argumnet but dont know how printf the arrays values? } { printf "%d" ,AMT??? }'END |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|