Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL Reflection (merged)
PL/SQL Reflection (merged) [message #360934] Mon, 24 November 2008 07:06 Go to next message
palhello
Messages: 15
Registered: November 2008
Junior Member
I need to do something like this
DECLARE
  abcd    VARCHAR2(100) := 'hello';
  Hello   VARCHAR2(100) := 'hello world';
  Output  VARCHAR2(100);
BEGIN
  Output := abcd;
  
  dbms_Output.Put_Line(Output);
  --need to print 'hello world'
  
END;


Is this possible in PL/SQL only ?

Thanks.

[Topic edited by LF: removed a duplicate post]

[Updated on: Mon, 24 November 2008 15:25] by Moderator

Report message to a moderator

Re: Reflection in PL/SQL [message #360938 is a reply to message #360934] Mon, 24 November 2008 07:15 Go to previous messageGo to next message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
Yes, set serveroutput on. For example:

SQL> SET SERVEROUTPUT ON SIZE 50000


Regards.

Frank
Re: PL/SQL Reflection [message #360999 is a reply to message #360934] Mon, 24 November 2008 10:51 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Yes .. You can .

Smile
Rajuvan.
Re: PL/SQL Reflection [message #361000 is a reply to message #360934] Mon, 24 November 2008 10:51 Go to previous messageGo to next message
Michel Cadot
Messages: 64132
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You could just ask to move your previous topic here.
And how the answer you got does not answer to your question?

Regards
Michel
Re: PL/SQL Reflection [message #361001 is a reply to message #360934] Mon, 24 November 2008 10:57 Go to previous message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
No. The closest approach is described in this thread on AskTom: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:227413938857#2973344838545.

Much more sensible approach would be using more "dynamic" variables, e.g. index-by tables:
SQL> set serveroutput on
SQL> declare
  2    type t_dict is table of varchar2(100) index by varchar2(100);
  3    l_dict t_dict;
  4    l_output varchar2(100);
  5  begin
  6    l_dict( 'hello' ) := 'Hello world';
  7    l_dict( 'true' ) := 'True world';
  8    l_dict( 'my' ) := 'My world';
  9  
 10    l_output := 'hello';
 11    dbms_output.put_line( l_output||' : '||l_dict (l_output) );
 12  end;
 13  /
hello : Hello world

PL/SQL procedure successfully completed.

But keep in mind that variable content is case sensitive.
Previous Topic: Numeric data from Character colomn and filter again with condtion
Next Topic: Random Time Between 2 dates
Goto Forum:
  


Current Time: Wed Dec 07 20:08:53 CST 2016

Total time taken to generate the page: 0.12623 seconds