- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- DB2 SQL from Shell Script
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
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
тАО09-25-2007 08:34 PM
тАО09-25-2007 08:34 PM
DB2 SQL from Shell Script
I want to run a DB2 script from the shell.
How can i do it?
I even want to accept an argument value from the user which i'l be substituting in the script & then execute the DB2 script by a shell script.
Please help me out...
tx in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 08:52 PM
тАО09-25-2007 08:52 PM
Re: DB2 SQL from Shell Script
General scripting rules will work here. Simplistic example.
arg1=$2
# second argument is in a variable, which can be used any way you like below
sqlplus -s ${DB_CONNECT} <
VALUES (
SYSDATE, 'backup_ref_data_dly.ksh', SYSDATE, 0, 'Backup of reference data - daily');
SHOW SQLCODE
end_sql
Note the general principle is to put what would normally be hand typed statements into the script line by line. Each line simulates an enter between <
Change the sqlplus to the proper DB2 equivalent and you can script darned near anything you want.
SEP
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
тАО09-25-2007 11:05 PM
тАО09-25-2007 11:05 PM
Re: DB2 SQL from Shell Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2007 03:46 AM
тАО09-26-2007 03:46 AM
Re: DB2 SQL from Shell Script
Yes.
He's showing you a shell script containing a "here-doc". That is the part from
bounded by "<
anything between those strings are sent, in this case, to the "sqlpus" command as if they were typed at the keyboard.
Note that their are rules about here-docs. from the sh-posix man page:
<<[-]word The shell input is read up to a line that matches word, or to an end-of-file. No parameter substitution, command substitution or file name generation is performed on word. The resulting document, called a here-document, becomes the standard input. If any character of word is quoted, no interpretation is placed upon the characters of the document. Otherwise, parameter and command substitution occurs, \newline is ignored, and \ must be used to quote the characters \, $, `, and the first character of word. If - is appended to <<, all leading tabs are stripped from word and from the document.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2007 03:57 PM
тАО09-26-2007 03:57 PM
Re: DB2 SQL from Shell Script
i have samples for calling Oracle or SQL Server SQLs from unix shell script... but
iam not finding script to call DB2 from shell script. thats what i wanted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2007 03:56 AM
тАО09-27-2007 03:56 AM
Re: DB2 SQL from Shell Script
also see here:
http://sqlrelay.sourceforge.net/sqlrelay/gettingstarted/db2.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2007 04:01 PM
тАО09-27-2007 04:01 PM
Re: DB2 SQL from Shell Script
Iam looking for samplee shell script which 1) connects to DB2
2) Fetches count from a table.
I just need exact syntax of how to connect to DB2 from shell script and fetch the count.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2007 01:56 AM
тАО09-28-2007 01:56 AM