SQLPLUS IN AWK Programming


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SQLPLUS IN AWK Programming
# 1  
Old 06-01-2012
SQLPLUS IN AWK Programming

Hi,

I am giving a call to SQLPLUS to query for something from a AWK session, but i am getting an error

Code:
"syntax error The source line is 4.
 The error context is
              >>>  l_count=` <<< 
 awk: The statement cannot be correctly parsed."

The code is:

Code:
awk '{
      if (substr($0,70,21) > 1 && substr($0,92,4)<3000) {
      l_cust_num=substr($0,1,25);
      l_count=`sqlplus -s apps/apps <<EOF
                 SET PAGES 0
                 SET FEED OFF
                 SET FEEDBACK OFF
                 SET LINESIZE 5000
                 SET HEADING OFF
                 SET VERIFY OFF
                 SET RECSEP OFF
                 SELECT COUNT(*) FROM oe_lookups WHERE lookup_type='RBC_POAO_CUSTOMER_LOOKUP' AND lookup_code=$l_cust_num;
                EXIT
                EOF`
       if $l_count > 0 {
       count=0;
       }
      }
      else {
       print $0;
      }
     }'

Let me know if i have to use this something different... I am using this for oracle apps script

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 06-01-2012 at 06:06 PM..
# 2  
Old 06-02-2012
You cannot include a HERE document inside an awk script. If I were doing it, I would determine the l_cust_num and then call the SQL script:


Code:
 
#!/bin/ksh
 
# UNTESTED 
l_cust_num=`awk '{
if (substr($0,70,21) > 1 && substr($0,92,4)<3000) {
    print substr($0,1,25)
  }
'}` 
 
# call the SQL script here

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk programming -Passing variable to awk for loop

Hi All, I am new to AWK programming. I have the following for loop in my awk program. cat printhtml.awk: BEGIN -------- <some code here> END{ ----------<some code here> for(N=0; N<H; N++) { for(M=5; M<D; M++) print "\t" D ""; } ----- } ... (2 Replies)
Discussion started by: ctrld
2 Replies

2. Shell Programming and Scripting

Sqlplus error - sqlplus -s <login/password@dbname> : No such file or directory

i am using bash shell Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127. IFS="," declare -a Arr=($Variable1); SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE} echo "set head off ; " > ${SQLCMD} echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Discussion started by: arghadeep adity
6 Replies

3. Shell Programming and Scripting

awk programming

Need assistance using awk . Need assistance in awk programming. Any idea of getting the marked data into a file. </tr> <tr> <td class='labelOptional_ind'> cdr.00012325.0000000000000000.20130612.050005.WANP4722_csv </td> <td width='15%' class='labelOptional'> <div align='center'>... (8 Replies)
Discussion started by: ajayram_arya
8 Replies

4. Shell Programming and Scripting

awk with variable from sqlplus

Hi, I'm a it stuck on the below code where a variable is pulled from sqlplus and used in awk. It runs with no errors but still pulls back all records in the input file. It should pull the max reference from sql plus and then only print those records where the reference value in column 1 is... (4 Replies)
Discussion started by: jonathanb30
4 Replies

5. Shell Programming and Scripting

AWK programming

Hi All, I read the AWK manual in the MAN page. But i didn't understand the below piece of code in the script TABLE=`echo "${FILE}" | awk -F"/" '{print $NF}' | cut -d"." -f1 | awk -F"_" '{print $NF}' 2>> ${LOGFILE}`; Please explain the above code. Thanks in advance ....... Regards,... (4 Replies)
Discussion started by: pdathu
4 Replies

6. Programming

awk programming

I have the list of numbers in a file 105.1 102.0 100.5 100 98 97.5 95 ... I want to get how many times I have numbers greater than a particular limit, say 100 in the list. How can I do that with awk command? (5 Replies)
Discussion started by: pranto_d
5 Replies

7. Shell Programming and Scripting

awk programming

Hi I have a multi -line file which is sorted by the 1-st colomn in the following format: 400 0000 0001 1000 1010 0111 0000 1000 0000 402 1101 0000 1100 1010 0111 1000 1000 0000 403 1001 0000 1100 1010 0111 0000 1000 0000 495 1000 0000 1100 ... (4 Replies)
Discussion started by: aoussenko
4 Replies

8. Shell Programming and Scripting

To pass the .sql file as a paramter to sqlplus through shell programming

Hi, Currently i have a .sql file 1.sql. I need to pass that as a parameter through a shell script to the sqlplus inside the same shell script. How I should I do.can anyone help me pls. I have an req where I need to send the .sql file and the place where the script has to create a .csv... (9 Replies)
Discussion started by: Hemamalini
9 Replies

9. Shell Programming and Scripting

need help with awk programming

Hello Friends I want to process only those lines which are not started with a * or " example File name: GRX "RxDataTime, NSysClkEn, Frame","Size","Sleep","TNum","TSet","TWait" *Init Start *Comment Generated from: C:\Documents and Settings 000000,0000,1,0,0,0,0,0,0... (8 Replies)
Discussion started by: user_prady
8 Replies

10. Shell Programming and Scripting

awk programming

Hi all, i want to study harder awk programming. where can i get a good examples, problems and solutions. i'm in a hurry.. thanks, (5 Replies)
Discussion started by: tungaw2004
5 Replies
Login or Register to Ask a Question