Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

spool to a dynamically created file

Status
Not open for further replies.

trainor24

Computer
Feb 14, 2003
2
I would like to spool a SQL result to a file. But, I want the file to change depending on what the user enters at a prompt. The problem I am having is that now I want part of my file name to be built depending on what the user enters.

For example, I want the file name to contain a year and some text. The text is conditional: if the user enters 1, then 'PNC'. If the user enters 2, then 'LAH' else 'NULL'.

ACCEPT yr PROMPT 'Enter Year: '
ACCEPT instype PROMPT 'Ins Type: '

DEFINE underscore = '_'
DEFINE ext = '.csv'
DEFINE report = 'CustomReports\D3F_&instype&underscore&yr&ext'
SPOOL &report

I do not really want to spool to a file called 'CustomReports\D3F_2_2002.csv'
Instead, I would rather spool to a file called 'CustomReports\D3F_LAH_2002.csv'

I tried using PL/SQL to build my file name but I am still having trouble.

Does anyone have any ideas?

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor