473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2038
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Leair | last post by:
I am using "from MyModule import *", (yes, yes, I know) MyModule has a variable "g_my_var" at the "global" scope. In the code that performs the import, I have a function that has the statement...
3
by: Thomas Matthews | last post by:
Hi, While coding programs, I cam about a conundrum regarding variables defined in an iterative loop. The issue is whether it is more efficient to factor the definition out of the loop or...
7
by: YGeek | last post by:
Is there any difference between declaring a variable at the top of a method versus in the code of the method? Is there a performance impact for either choice? What about if the method will return...
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
4
by: Ray | last post by:
Hello, I think I've had JavaScript variable scope figured out, can you please see if I've got it correctly? * Variables can be local or global * When a variable is declared outside any...
7
by: Max | last post by:
Please somebody can shed a light... How can I have a variable visible and modifiable, inside one and only webform? I mean , I d like to see that variable from all the Sub of that webform code,...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
14
by: subramanian100in | last post by:
Consider the following program: #include <iostream> using namespace std; int main() { int i;
4
Dheeraj Joshi
by: Dheeraj Joshi | last post by:
Hi, I was wondering is there any technique available, so we can access the global variable inside a function if we have a local variable inside the function with the same name as global variable. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.