passing value of sqlplus variable from one script to another.

Posted by FrustratedWithFormsDesigner on Stack Overflow See other posts from Stack Overflow or by FrustratedWithFormsDesigner
Published on 2010-04-14T21:51:00Z Indexed on 2010/04/14 21:53 UTC
Read the original article Hit count: 345

Filed under:
|
|

I have a script that gets the current time, and must pass it to another script.

variable v_s_time varchar2(30);
exec :v_s_time := to_char(sysdate,'YYYY-MM-DD HH:MI:SS AM');
--Lots of unrelated code here
variable v_e_time varchar2(30);
exec :v_e_time  := to_char(sysdate,'YYYY-MM-DD HH:MI:SS AM');
@"test report script.sql" :v_s_time :v_e_time; --yes, I also tried ":v_s_time", didn't seem to do anything.

This does not work, it seems that the literal :v_s_time is passed to the script, instead of what I want: "2010-04-14 05:50:01 PM".

To execute this manually, I could enter:

@"test report script.sql" "2010-04-14 05:50:01 PM" "2010-04-14 05:57:34 PM"

I found that what does work is this:

define v_s_time = "2010-04-14 05:50:01 PM"
--Lots of unrelated code here
define v_e_time = "2010-04-14 05:57:34 PM"
@"test report script.sql" "&&v_s_time" "&&v_e_time";

But it is unrealistic to hardcode the datetimes. Anyone know how to handle this?

(Oracle 10g)

© Stack Overflow or respective owner

Related posts about sqlplus

Related posts about Oracle