Unix oracle script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix oracle script
# 1  
Old 05-28-2012
Unix oracle script

Hi All ,

I am trying to get the count of the record in a table into a file or a variable .


Code:
set heading off
set feedback off
set linesize 20
set pages 0
set newpage 0
set verify off
spool test.txt

select count(*) from test_data where dfu_load_date='23/05/2012' and campaign_code='sd1';
quit;
spool off;
END
cnt=`wc -l test.txt `
echo "The records uploaded= ${cnt}"

Now from above script i am trying to get the count into a spool file and the pic the count from there.

Could someone please suggest any way from which i can get the count of the records into a variable or txt file.

Thanks,
Preetpal

Last edited by Scrutinizer; 05-28-2012 at 11:46 AM.. Reason: code tags
# 2  
Old 05-28-2012
Try..
Code:
wc -l test1.txt| awk '{print $1}'

# 3  
Old 05-28-2012
Hi ,

I am getting following result in text1.txt
from which i cant fetch the row count

Code:
SQL>
SQL> select count(*) from test_data where dfu_load_date='23/05/2012' and campaign_code='sd1';
       498
SQL>


Last edited by Scrutinizer; 05-28-2012 at 11:46 AM.. Reason: code tags
# 4  
Old 05-28-2012
Can you post the text1.txt file content...
# 5  
Old 05-28-2012
Hi
You can try any one of the ways mentioned here: retrieve data from sqlplus into a variable
# 6  
Old 05-28-2012
Quote:
Originally Posted by guruprasadpr
Hi
You can try any one of the ways mentioned here: retrieve data from sqlplus into a variable
Note: That link contains some errors though, since EOF is not at the beginning of the line in the examples. And the double quotes are wrong and cannot be cut-and-pasted...

Last edited by Scrutinizer; 05-28-2012 at 12:31 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 7  
Old 05-28-2012
@scrutinizer: Thanks for pointing it out.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing Oracle script from UNIX Script

Hi, I am new to UNIX and want to execute oracle script from unix script. I have written below script but i am getting below error. #!/bin/bash file="/home/usr/control/control_file1" while read line do #$line=@$line #echo $line sqlplus tiger/scott@DB @$line exit #echo "$line" done... (3 Replies)
Discussion started by: vipin kumar rai
3 Replies

2. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

3. UNIX for Advanced & Expert Users

Use of Oracle pl/sql in UNIX shell script

Hi, I have basic knowledge on how to write pl/sql code inside shell script. I am looking for more advance thing. Is there any book for that which can just talk about how to write more advance plsql code inside shell script. Please help Thanks!!!!!! (1 Reply)
Discussion started by: diehard
1 Replies

4. Shell Programming and Scripting

PROBLEM WITH ORACLE QUERY IN UNIX SCRIPT

hi Guys, i have a problem with oracle query in my unix script.. I'm getting the following error while executing.. ./logtab.sh: sqlplus -s "pmutv/pmutv1" << EOFSQL^Jset head off^Jinsert into... (2 Replies)
Discussion started by: apple2685
2 Replies

5. Shell Programming and Scripting

Need to access Oracle DB with shell/perl script in Unix

Hi, We need to access Oracle DB with shell/perl script in Unix. Is Oracle client needed in Unix for this. I have seen threads which tell abt using SQL plus to access Oracle tables. Can we access DB without SQL PLus installation using scripts in UNix like we access DB using jar files in Java .... (1 Reply)
Discussion started by: justinacc
1 Replies

6. Shell Programming and Scripting

How to fetch data from oracle in unix shell script

Hi, How to fetch data from oracle database in unix shell scripting. list=`sqlplus -s ds_user/dsuser@EMI <<EOF set feedback off set serveroutput on set heading off set pagesize 0 set tab off select IP_ID from table / exit EOF` The output is not what i expected.I need output in... (4 Replies)
Discussion started by: Anusha_Reddy
4 Replies

7. Shell Programming and Scripting

Delete oracle table from UNIX script

Hi, Is it possible to delete oracle table datas using a UNIX script/Shell script? how can we do this?? I have oracle Database and i have to delete millions of record everyday.. adn it is taking hours togather to execute this. Will the delete query triggered from UNIX be faster can we expect any... (1 Reply)
Discussion started by: Codesearcher
1 Replies

8. HP-UX

return code from oracle to unix script

Hi I'm writing a shell script that connects to oracle database and fires query to check the availability of data in a table. In case of no data found then what will be the return code and how to handle in that in variable. Kindly provide with an example for better understanding... Thanks... (1 Reply)
Discussion started by: ksailesh
1 Replies

9. UNIX for Dummies Questions & Answers

Unix shell script Certification for oracle developer.

hi friends, I would like to do the certification in Korn shell scripts { i am using HP UNIX machine }. is there any certification for UNIX shell script . If yes please tell me the details . i am junior level oracle plsql developer . i interseted in unix shell scripting . i need... (1 Reply)
Discussion started by: rdhaprakasam
1 Replies

10. Shell Programming and Scripting

Executing a Oracle SQL statement in a UNIX script

Hi All, I need to select one column from a table based upon the passed in parameter. I tried this: sqlplus -silent $MISP_USER << EOF set feedback off; set verify off; set sqlprompt "" SELECT mail_flag FROM dailyjobs WHERE job_name = '$1'; exit 0 EOF exit... (1 Reply)
Discussion started by: ganga.dharan
1 Replies
Login or Register to Ask a Question