dbTalk Databases Forums  

bind within functions

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss bind within functions in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
felixpfrunder@gmx.net
 
Posts: n/a

Default bind within functions - 05-24-2005 , 02:46 AM






I would like to set a bind variable within a function

I tried the following:

VARIABLE x NUMBER

CREATE OR REPLACE FUNCTION setX
RETURN NUMBER IS
BEGIN
:x := 2;
RETURN 0;
END;
/

but I received the syntax error

4/3 PLS-00049: bad bind variable 'X'

How have I to declar x

Thanks


Reply With Quote
  #2  
Old   
Carlos
 
Posts: n/a

Default Re: bind within functions - 05-24-2005 , 02:59 AM






SQL> CREATE OR REPLACE PROCEDURE setX (p_x IN OUT NUMBER )
2 is
3 BEGIN
4 p_x := 2;
5 END;
6 /

Procedimiento creado.

SQL> VARIABLE x NUMBER

SQL> EXEC setX(:x);

Procedimiento PL/SQL terminado correctamente.

SQL> print x

X
----------
2

Cheers.


Reply With Quote
  #3  
Old   
Chris \( Val \)
 
Posts: n/a

Default Re: bind within functions - 05-24-2005 , 07:21 AM




<felixpfrunder (AT) gmx (DOT) net> wrote

Quote:
I would like to set a bind variable within a function

I tried the following:

VARIABLE x NUMBER

CREATE OR REPLACE FUNCTION setX
RETURN NUMBER IS
BEGIN
:x := 2;
RETURN 0;
END;
/

but I received the syntax error

4/3 PLS-00049: bad bind variable 'X'

How have I to declar x
I'm just an occasional dabbler in PL/SQL (and someone
will no doubt correct me if I'm wrong), but AFAIK, all
PL/SQL variables are naturally bind variables, so there
is no need for explicit qualification, unless using
dynamic SQL, IIRC.

Cheers,
Chris Val




Reply With Quote
  #4  
Old   
DA Morgan
 
Posts: n/a

Default Re: bind within functions - 05-24-2005 , 11:07 AM



Chris ( Val ) wrote:
Quote:
felixpfrunder (AT) gmx (DOT) net> wrote in message
news:1116920798.018251.38600 (AT) g49g2000cwa (DOT) googlegroups.com...
|I would like to set a bind variable within a function
|
| I tried the following:
|
| VARIABLE x NUMBER
|
| CREATE OR REPLACE FUNCTION setX
| RETURN NUMBER IS
| BEGIN
| :x := 2;
| RETURN 0;
| END;
| /
|
| but I received the syntax error
|
| 4/3 PLS-00049: bad bind variable 'X'
|
| How have I to declar x

I'm just an occasional dabbler in PL/SQL (and someone
will no doubt correct me if I'm wrong), but AFAIK, all
PL/SQL variables are naturally bind variables, so there
is no need for explicit qualification, unless using
dynamic SQL, IIRC.

Cheers,
Chris Val
Correct. There is no value in doing what was done above
except in NDS.
--
Daniel A. Morgan
http://www.psoug.org
damorgan@x.washington.edu
(replace x with u to respond)


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.