How to load a SQL*Plus variable with data from a query

I’ve often had a SQL script that I want to run in SQL*Plus and I need to query some data from the database and put it in a variable. It is quite simple to do if you know how.

This is an example of retrieving the schema name:

column schemaname new_value schemaname
select sys_context('USERENV','CURRENT_SCHEMA') schemaname from dual;

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s