Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pass parameters to anonymous block executed in sqlplus

user8276789Jan 12 2015 — edited Jan 12 2015

Hello,

I executed sql file with parameters (anonymous block with many with clauses) in sqlplus:

@sqlFile.sql '11/06/2014' '11/07/2014'

sqlFile.sql :

var start_date varchar(11) := '&1';

var end_date varchar(11) := '&2';

BEGIN

dbms_output.put_line('start ' || '&1');

dbms_output.put_line('end' || :end_date);

with findDates as

(

select d.date

from dates d

where d.date > :start_date && d.date < :end_date

)

select * from findDates;

END;

/

In put_line for start_date value were changed - I saw old and new log in console.

For end_date I got error: Bind variable "end_date" not defined.

Is my syntax for variables in with clause correct? Why my variable are not visible for sql code?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 9 2015
Added on Jan 12 2015
7 comments
5,499 views