- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- From within SQL spooling output file whose name us...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2004 03:00 AM
тАО01-21-2004 03:00 AM
I would like to spool out a file from within sql that uses as its name the time from sysdate.
eg. SYSDATE is now = 16:15 Wed 21 Jan 2004
I would like to spool a file whose name is
report_210120041615.lst. Can anyone please help.
Thanks for your help.
Dave
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2004 03:12 AM
тАО01-21-2004 03:12 AM
Re: From within SQL spooling output file whose name uses sysdate
export file_name=report_`date`.lst
sqlplus user/passwd@db
myquery.sql is a file that contains your query.
See also man page of date for your favorite date-format.
Regards,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2004 03:13 AM
тАО01-21-2004 03:13 AM
SolutionIt's a bit fiddly.
Something along these lines would do the trick...
col spooldest new_value v_spooldest noprint
select 'report_'||to_char(sysdate,'DDMMYYYYHHMM') spooldest from dual ;
spool &&v_spooldest
-- your sql here
spool off
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2004 06:37 PM
тАО01-21-2004 06:37 PM
Re: From within SQL spooling output file whose name uses sysdate
sqlplus -s kp/exa@db << EOF
spool /tmp/kak/hel_new/sort.lst
@/tmp/kak/hel_sql/check_sort_types.sql
spool off
exit
EOF
# Renaming the File and adding date for it
#
mv /tmp/kak/hel_new/sort.lst /tmp/kak/hel_new/sort.lst.`date +%a%d%b`
#
if [ -r "/tmp/kak/hel_new/sort.lst.`date +%a%d%b`" ]
then
lp /tmp/kak/hel_new/sort.lst.`date +%a%d%b`
else
echo " Cant Locate File /tmp/kak/hel_new/sort.lst.`date +%a%d%b`" > /tmp/kak/hel_new/sort.err
fi
You can play around with the date part i.e
sort.lst.`date +%a%d%b` till u get what u are after.
kyris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2004 07:42 PM
тАО01-21-2004 07:42 PM
Re: From within SQL spooling output file whose name uses sysdate
this is the way I usually use to have in the sp[ool file name the name of the instance and the sysdate:
/* Define the name of the spoolfile */
col spool_file_name new_value spool_file_name noprint
col file_name new_value file_name noprint
col file_date new_value file_date noprint
select '
select to_char(sysdate,'yyyyymmdd') file_date from dual;
select '&file_name'||'&file_date'||'.log' spool_file_name from dual;
spool &spool_file_name
.... your sql statement ...
spool off
I hope it help.
Art