home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,454 of 2,288   
   Frank van Bortel to Dean Pearson   
   Re: Variable inside a variable   
   30 May 04 19:40:40   
   
   From: fvanbortel@netscape.net   
      
   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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca