Home » SQL & PL/SQL » SQL & PL/SQL » Column Keyword
icon5.gif  Column Keyword [message #215733] Tue, 23 January 2007 12:54 Go to next message
Messages: 11
Registered: January 2007
Junior Member
The below line is from one of the post which I am unable to understand. Would some one pls help what the line in bold means.

I dont know how column keyword works!

column v_filename new_value v_filename
select 'extract1.txt' as v_filename from dual;
spool &v_filename

Re: Column Keyword [message #215742 is a reply to message #215733] Tue, 23 January 2007 14:20 Go to previous message
Barbara Boehmer
Messages: 8737
Registered: November 2002
Location: California, USA
Senior Member
The COLUMN column_name_or_alias NEW_VALUE variable_name is a SQL*Plus command used to store the new value of the column name or alias to a variable, so that the variable can be used for other things, such as in the spool command, or more commonly in a SQL*Plus ttitle or btitle of a report. The example that you saw used the same name for both the column alias and variable name. It might be less confusing as:

COLUMN column_alias NEW_VALUE variable_name
SELECT 'extract1.txt' AS column_alias FROM DUAL;
SPOOL &variable_name

Each time the column value changes, the variable value changes. The example that you extracted from the earlier post was just the minimal changes to the original poster's code to make it run without error, and not necessarily the most efficient or best way to write it. With only one filename, it could have just as easily been spooled directly to the filename, without the rest of the code. You can find more information and examples by searching for new_value in the SQL*Plus users's guide in the online documentation.

Previous Topic: Analytic with Count
Next Topic: Best Logic for retriving data based on timestamp.
Goto Forum:

Current Time: Fri Aug 18 22:50:48 CDT 2017

Total time taken to generate the page: 0.10952 seconds