469,090 Members | 1,163 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,090 developers. It's quick & easy.

Variable inside a variable

This is a little hard to explain, but please bear with me ...

I'm writing a package in PL/SQL and in one of my procedures I am
retrieving data from a db table. This table has a column which
possibly has a variable name in it.

By using a cursor I have a variable holding the value which is another
variable name of the. How can i use the variable I have with dsql so
that i have a sql statement that gives uses the value of the variable
that is named in the initial variable.

eg

v_myVar1 := 'foo';
v_myVar2 := 'v_myVar1';

v_sqlString := 'SELECT '||v_myVar2||' FROM DUAL';

it will give me v_myVar1 when i want the output to be foo!??!

I'm guessing i want some like eval that executes the variable then
parses it to the string.

Does anyone have any ideas?

Thanks in advance
Jul 19 '05 #1
1 1901
Dean Pearson wrote:
This is a little hard to explain, but please bear with me ...

I'm writing a package in PL/SQL and in one of my procedures I am
retrieving data from a db table. This table has a column which
possibly has a variable name in it.

By using a cursor I have a variable holding the value which is another
variable name of the. How can i use the variable I have with dsql so
that i have a sql statement that gives uses the value of the variable
that is named in the initial variable.

eg

v_myVar1 := 'foo';
v_myVar2 := 'v_myVar1';

v_sqlString := 'SELECT '||v_myVar2||' FROM DUAL';

it will give me v_myVar1 when i want the output to be foo!??!

I'm guessing i want some like eval that executes the variable then
parses it to the string.

Does anyone have any ideas?

Thanks in advance


Look up 'execute immediate using ... returning ...'
Bind variables, so scalable. Does not work for DDL (which
you should want to use in this manner, anyway)
--

Regards,
Frank van Bortel

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Brian Leair | last post: by
3 posts views Thread by Thomas Matthews | last post: by
2 posts views Thread by Thomas Matthews | last post: by
23 posts views Thread by Russ Chinoy | last post: by
7 posts views Thread by Max | last post: by
pbmods
1 post views Thread by pbmods | last post: by
14 posts views Thread by subramanian100in | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.