dbTalk Databases Forums  

sqlplus bind variable question

comp.databases.oracle.server comp.databases.oracle.server


Discuss sqlplus bind variable question in the comp.databases.oracle.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chuck
 
Posts: n/a

Default sqlplus bind variable question - 09-29-2010 , 10:53 AM






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

Reply With Quote
  #2  
Old   
John Hurley
 
Posts: n/a

Default Re: sqlplus bind variable question - 09-29-2010 , 02:45 PM






On Sep 29, 11:53*am, Chuck <chuckh1958_nos... (AT) gmail (DOT) com> wrote:
Quote:
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
You have to work with the one out of the set of valid variable names
in sqlplus ... 1 is not legal.

Reply With Quote
  #3  
Old   
Mark D Powell
 
Posts: n/a

Default Re: sqlplus bind variable question - 10-01-2010 , 11:05 AM



On Sep 29, 3:45*pm, John Hurley <hurleyjo... (AT) yahoo (DOT) com> wrote:
Quote:
On Sep 29, 11:53*am, Chuck <chuckh1958_nos... (AT) gmail (DOT) com> wrote:





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

You have to work with the one out of the set of valid variable names
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 --

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.