Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    57

    Question Unanswered: 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 06:31.

  2. #2
    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

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •