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 > Receive input parameters in a sql file? Is it posible?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-04, 11:23
AStefan AStefan is offline
Registered User
 
Join Date: Jun 2004
Posts: 57
Question Receive input parameters in a sql file? Is it posible? Urgent please.

I must generate a database and all database objects.
For that I have some sql files and a .bat file (Windows).
In Oracle I use the commands define and prompt and take from the .bat the input parameters. In SQL Server I use the system database master where I create a table and write there the parameters (database name for example).
Is it possible in a db2sql file to receive an input parameter?
For example in the .bat i have something like that

set Database_Name=%1

How can I use this information in a db2 sql file?
I cannot use the sql server solutions because I don't have system databases.
Thanks for your help.

Last edited by AStefan; 06-24-04 at 05:31.
Reply With Quote
  #2 (permalink)  
Old 06-24-04, 09:11
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by AStefan
I must generate a database and all database objects.
Sounds like a job for db2look.

Quote:
Originally Posted by AStefan
For that I have some sql files and a .bat file (Windows).
In Oracle I use the commands define and prompt and take from the .bat the input parameters. In SQL Server I use the system database master where I create a table and write there the parameters (database name for example).
Is it possible in a db2sql file to receive an input parameter?
For example in the .bat i have something like that

set Database_Name=%1

How can I use this information in a db2 sql file?
I cannot use the sql server solutions because I don't have system databases.
Thanks for your help.
Unfortunately db2 doesn't have anything like that for the sql file. Although for DBNAME you can use db2set DB2DBDFT=MYDB and just do CONNECT with no options.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 06-24-04, 11:40
AStefan AStefan is offline
Registered User
 
Join Date: Jun 2004
Posts: 57
Create Database in a bat

Finally I used two .bat files.
I have the parameters user, server, password and database name.
I connect to the idle instance (force to use connect reset because either I ewas connected to a database, I don't know which one?)
In the second .bat file I create the database and then I run the sql files with the other objects (tablespaces, tables etc)
The only solution is to create the database in the bat and not in the sql file.
Thanks.
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