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 > pass system environment variables into sql script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-22-10, 15:19
spandit3 spandit3 is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
pass system environment variables into sql script

Hi, I was wondering how to pass system environment variables into sql script. Basically I have a bat file that setups tablespaces based on project names, and I would like to update my create table sql file to use the tablespaces defined in the bat file. is this possible?

for example lets say I have this

setEnv.bat
set TABLESPACE=ProjectA


createTable.sql
CREATE TABLE TEST
(
textA VARCHAR(3) NOT NULL,
textB VARCHAR(3) NOT NULL
) IN %TABLESPACE%;
Reply With Quote
  #2 (permalink)  
Old 06-22-10, 22:02
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Can you pass it as an argument to a shell script. Something like:

$ more create.table
db2 connect to sample
db2 "create table testt (c1 int, c2 int) in $*"


$ ./create.table userspace1

Database Connection Information

Database server = DB2/AIX64 9.7.2
SQL authorization ID = xxxxxx
Local database alias = SAMPLE

DB20000I The SQL command completed successfully.
Reply With Quote
  #3 (permalink)  
Old 06-23-10, 13:42
spandit3 spandit3 is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
thanks that worked....

another question how do I import data into a specified table in a table space.

tried this but no luck
db2 "import from TAG.ixf of ixf COMMITCOUNT 100 messages TAG.log insert into TAG IN %TABLESPACE%"
Reply With Quote
  #4 (permalink)  
Old 06-23-10, 17:51
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
use import/insert into an existing table without specifying the tablespace or import/create into a new table and specify the tablespace
Reply With Quote
Reply

Tags
db2, environment, pass, sql, variables

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