Or you could try this:
Main Topics
Browse All TopicsCan anyone advise-How can i retreive the output of following test sql file and used in bash script further. I am using following sqlplus line in bash script. i want the cnt value to be passed to bash script where cnt is a varable used in test.sql to store output.
sqlplus xx/xx@DNYNTK01 @test.sql
The test.sql file contains-
set serveroutput on size 200000
set linesize 200
set feedback on
declare
v_exception date;
cnt integer;
begin
select Case When To_Number(To_Char(Sysdate,
Then (select trunc(sysdate+1) from dual) Else trunc(sysdate) End into v_exception from dual;
select count(*)into cnt from Cust where E_DATE=to_date(v_exception
dbms_output.put_line(cnt);
end;
/
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Give this a try. It's basically the same as the scripts in you other threads with a minor tweak:
#!/usr/bin/bash
var=$
echo "I got: " $var
In you .sql file, you're missing the end 'exit' and you need to set feedback off not on.
MikeOM_DBA,
I'm not sure what the final goal is here. This is the 3rd variation of pretty much the same question.
Please check out:
http://www.experts-exc
http://ww
Business Accounts
Answer for Membership
by: flow01Posted on 2009-11-07 at 06:17:15ID: 25766398
a) change test.sql to
st 'HH24')) >= 19 -15); ter: ' || cnt);
st | cut -d' ' c2`
1. spool the output to a file
2. ad a unique marker to line with counter
b) modify your script to extract the value
ad a)
set serveroutput on size 200000
set linesize 200
set feedback on
spool yourdirectory/testoutput.l
declare
v_exception date;
cnt integer;
begin
select Case When To_Number(To_Char(Sysdate,
Then (select trunc(sysdate+1) from dual) Else trunc(sysdate) End into v_exception from dual;
select count(*)into cnt from Cust where E_DATE=to_date(v_exception
dbms_output.put_line('coun
end;
/
spool off
ad b)
i don't kwow bash script
but in korn shell it would look like
sqlplus xx/xx@DNYNTK01 @test.sql
CNT=`grep counter yourdirectory/testoutput.l
# select the line containing counter from output list
# split the selected line in columns separated by a space
# take second columns of the line
# assign the value to CNT