If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 Passing parameter from os shell windows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-04, 12:44
ronenshi ronenshi is offline
Registered User
 
Join Date: Sep 2004
Posts: 33
DB2 Passing parameter from os shell windows

Hi,
I need to create a batch script that create tablespace and schema , the batch file suppose to pass this 2 parms to an sql file that will create the objects.
How it can be done?

10x
Reply With Quote
  #2 (permalink)  
Old 10-04-04, 13:08
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Code:
#!/bin/sh
db2 -t <<!eof
create tablespace $1 managed by system using ('$2');
commit;
!eof
The shell will substitute the values of the command line arguments ($1 and $2) given to the script before passing the strings to db2.
Reply With Quote
  #3 (permalink)  
Old 10-04-04, 13:11
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Oh, it's on Windows... I guess you'll have to install Cygwin :-)
Reply With Quote
  #4 (permalink)  
Old 10-04-04, 13:20
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
But still...
Code:
@echo off
echo create tablespace %1 managed by system using ('%2'); > tmp.sql
echo commit; >> tmp.sql
db2 -tf tmp.sql
if errorlevel 0 del tmp.sql
Reply With Quote
  #5 (permalink)  
Old 10-05-04, 06:49
ronenshi ronenshi is offline
Registered User
 
Join Date: Sep 2004
Posts: 33
10x that was very helpfull, if i have multi statements i'll have 2 use the echo command or is their another way?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On