- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- SQL query in CRONTAB
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-06-2003 01:00 PM
тАО01-06-2003 01:00 PM
SQL query in CRONTAB
I want to get the data from a table and put them into a file (in the Operating System). I have a database over a Unix System. What's the command that do I have to ejecute?
Then, this command I want to program it in the crontab.
Thank you very much!!!
Programming a command SQL in the crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2003 01:03 PM
тАО01-06-2003 01:03 PM
Re: SQL query in CRONTAB
http://www.princeton.edu/~storacle/perldbi.shtml
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2003 02:09 PM
тАО01-06-2003 02:09 PM
Re: SQL query in CRONTAB
oracle/oracle@jufprod
Thats your oracle user id, oracle password and instance name.
Obviously, this is not a great thing to have in a script.
The book Perl Cookbook has methodology for dealing with the security issues in a better way.
And no, our oracle password is not oracle, just in case anyone wants to point out the obvious.
Steve
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2003 09:08 PM
тАО01-06-2003 09:08 PM
Re: SQL query in CRONTAB
I have a script that convert a Oracle table into a flat file.
E.g.
============================================================
L-oracle8i: home/yd/flat>flat.sh scott/tiger emp
7369 SMITH CLERK 7902 17/12/1980 968 20
7499 ALLEN SALESMAN 7698 20/02/1981 1600 300 30
7521 WARD SALESMAN 7698 22/02/1981 1250 500 30
7566 JONES MANAGER 7839 02/04/1981 2975 20
7654 MARTIN SALESMAN 7698 28/09/1981 1250 1400 30
7698 BLAKE MANAGER 7839 01/05/1981 2850 30
7782 CLARK MANAGER 7839 09/06/1981 2450 10
7788 SCOTT ANALYST 7566 09/12/1982 3000 20
7839 KING PRESIDENT 17/11/1981 5000 10
7844 TURNER SALESMAN 7698 08/09/1981 1500 0 30
7876 ADAMS CLERK 7788 12/01/1983 1100 20
7900 JAMES CLERK 7698 03/12/1981 950 30
7902 FORD ANALYST 7566 03/12/1981 3000 20
7934 MILLER CLERK 7782 23/01/1982 1300 10
9876 REEVES ANALYST 7839 12/01/2085 3000 200 60
7999 PIERO CLERK 7839 20/02/1999 2000 30
7991 RAUL CLERK 7839 12/05/1991 1200 61
7989 HESKEY 1000 20
============================================================
Scripts are attached.
Now, if you want to "cron" it:
(the easiest way will be to use root account and switch user to run this script)
============================================================
# crontab -l
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
00,30 08,09 * * * echo "/home/yd/flat/flat.sh scott/tiger emp dept > /home/yd/flat/myflatfile.txt"|su - oracle8i 1>/home/yd/flat/logfiles/output-flat.crn 2>/home/yd/flat/logfiles/error-flat.crn
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
============================================================
(NB. this cronjob "exports" 2 tables emp and dept)
The output can also be formatted for Excel or any spreadsheet that understands the industry standard SYLK file format or even in SQLLOADER format that can be used to import in another database.
If you need any further help, please let use know.
Hope this helps!
Best Regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2003 09:12 PM
тАО01-06-2003 09:12 PM
Re: SQL query in CRONTAB
forgot the attachments and sorry for the formatting of the output ;)
Cheers
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2003 09:14 PM
тАО01-06-2003 09:14 PM
Re: SQL query in CRONTAB
the second file
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-06-2003 09:14 PM
тАО01-06-2003 09:14 PM
Re: SQL query in CRONTAB
the second file
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2003 01:55 AM
тАО01-07-2003 01:55 AM
Re: SQL query in CRONTAB
Put an entry in crontab similar to:
00 15 * * 1-5 su - oracle -c "/path/script" > /dev/null 2>&1
The script should be something like:
sqlplus /nolog <
select ...
EOF
Hope this helps,
Raimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2003 06:43 AM
тАО01-07-2003 06:43 AM
Re: SQL query in CRONTAB
Thank you by your suggestions.
I send a report about the table that I want to analize.
How Can I adapt it in your script flat.sh, Please?
I'd like that you send me the script with these parameters.
Thank you very much!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2003 10:54 PM
тАО01-07-2003 10:54 PM
Re: SQL query in CRONTAB
You can spool the output of the select statements into a text file in the file system.
Eg:- Logon to SQLPLUS and the at the SQL prompt type this.
Spool test_report.txt
select
where
spool off
When you exit from SQLPLUS you list for test_report.txt file, you will see az text file and this will have the selected field name. You can format them as well.
Then cron job this script with the complete path to be executed daily / weekly.... depending on your requirements.