Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sqlplus bind variable question

21 views
Skip to first unread message

Chuck

unread,
Sep 29, 2010, 11:53:11 AM9/29/10
to
Recently on an SR, Oracle asked me to run a SELECT that included bind
variables named :1 and :2. Is it even possible to do that in sqlplus?
The only way I know of to make it work is to change the variable names
so that they start with a letter (eg :b1 and :b2). Is there a way to do
it without changing the names?

example:

var 1 varchar2(20)
exec :1 := 'abc';

That doesn't work, but this does...

var b1 varchar2(20)
exec :b1 := 'abc';
print b1

John Hurley

unread,
Sep 29, 2010, 3:45:20 PM9/29/10
to

You have to work with the one out of the set of valid variable names
in sqlplus ... 1 is not legal.

Mark D Powell

unread,
Oct 1, 2010, 12:05:24 PM10/1/10
to
> in sqlplus ... 1 is not legal.- Hide quoted text -
>
> - Show quoted text -

Here is an example:

SQL> select * from marktest where fld2 = 1;

FLD1 FLD2 FLD3
---------- ---------- ---------
moe 1 24-AUG-10


SQL> @t98
SQL> set echo on
SQL> variable v1 varchar2(10)
SQL> variable v2 number
SQL> begin
2 :v2 := 1;
3 select fld1 into :v1 from marktest
4 where fld2 = :v2;
5 end;
6 /

PL/SQL procedure successfully completed.

SQL> print :v1

V1
--------------------------------
moe


HTH -- Mark D Powell --

0 new messages