PDA

View Full Version : Sysdate in Filename for spool Command


Thomas Kindermann
11-07-2003, 01:29 AM
Hi,
another question, i hope it is the last:

How can i use the spool command with the sysdate function ?

Thanks

Thomas Kindermann
Oracle Admin

mcstock
11-07-2003, 04:00 AM
there is no inherent relationship between the two, and it's not at all clear
what you're asking -- but i'll take a stab at it anyway ;-)

if you mean you'd like to include the current date and/or time in the spool
filename, then look into using the COLUMN xxx NEW_VALUE, which populates a
SQL*Plus substitution ('define') variable based on the value of a column in
a SELECT statement -- the variable can then be used with the SPOOL command

"Thomas Kindermann" <tkinder@gmx.de> wrote in message
news:3fab6530$0$41436$45beb828@newscene.com... Hi, another question, i hope it is the last: How can i use the spool command with the sysdate function ? Thanks Thomas Kindermann Oracle Admin

Daniel Morgan
11-07-2003, 08:46 AM
Thomas Kindermann wrote:
Hi,another question, i hope it is the last:How can i use the spool command with the sysdate function ?ThanksThomas KindermannOracle Admin
Making a wild stab at what you are asking as your question is very
ambiguous and you
have not included any version information.

SELECT TO_CHAR(SYSDATE, 'MM/DD/YYYY')
FROM some_table;

--
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan@x.washington.edu
(replace 'x' with a 'u' to reply)

Dave
11-07-2003, 09:54 AM
mcstock wrote: there is no inherent relationship between the two, and it's not at all clear what you're asking -- but i'll take a stab at it anyway ;-) if you mean you'd like to include the current date and/or time in the spool filename, then look into using the COLUMN xxx NEW_VALUE, which populates a SQL*Plus substitution ('define') variable based on the value of a column in a SELECT statement -- the variable can then be used with the SPOOL command "Thomas Kindermann" <tkinder@gmx.de> wrote in message news:3fab6530$0$41436$45beb828@newscene.com...Hi,another question, i hope it is the last:How can i use the spool command with the sysdate function ?

Working code for his explanation ...


column spool_date new_value spool_date

select to_char(sysdate, 'dd-mon-yyyy') spool_date
from dual
/

spool my_file_&&spool_date..txt


--
Richard Kuhler


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service