Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substitution variables from a table

Status
Not open for further replies.

SteveCulshaw

Programmer
Oct 13, 2000
48
0
0
GB
Is there anyway to get a value from a select into a variable ?
e.g. define report_user select user from dual
so I can do some work later in the SQL script Cheers,
Steve C.
 
Don't you use the SELECT something INTO variablename ... format? I haven't used it in a while, but I think it is something like that. Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
In plain SQL it doesn't work, the only way I've found is to use PL/SQL

DECLARE
report_user VARCHAR2(200);
BEGIN
SELECT USER
INTO report_user
FROM dual;
DBMS_OUTPUT.put_line(' User is : ' || report_user);
END;
/ Cheers,
Steve C.
 
You can set user-variables via new_value:
define report_user=''
column rep_usr noprint new_value report_user
select user rep_usr from dual;

You can use the variable in tti without the define-part it.

Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top