Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: Execute SQL's from Command Windows with parameter my_table_name

    Hi,

    On "DB2 v8.1 fp2 for Windows 2000" I would like to execute SQL statements from DB2 Command Window with parameter 'my_table_name'?

    Sample
    script_name my_table_name

    Old fashion way
    Now I have to open SQL file, change 'my_table_name' to table name and then execute it at DB2 Command Window. To do all this tasks over and over is very time consuming. Is it any way to do this from Command Window? It can be with batch or without batch file. Just giving me some idea would be very usefull to me.

    I have folowing SQL:
    SELECT
    SUBSTR(A.TBCREATOR,1,20) AS TABSCHEMA,
    SUBSTR(A.TBNAME,1,20) AS TABNAME,
    SUBSTR(A.COLNAME,1,20) AS COLNAME,
    SUBSTR(A.CONSTNAME,1,18) AS CONSTNAME
    FROM
    SYSIBM.SYSKEYCOLUSE A,
    SYSIBM.SYSTABCONST B
    WHERE
    A.CONSTNAME = B.NAME
    AND B.CONSTRAINTYP='P'
    AND A.TBCREATOR = 'my_table_name'

    Thanks,
    Grofaty
    Last edited by grofaty; 11-13-03 at 15:31.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Execute SQL's from Command Windows with parameter my_table_name

    Originally posted by grofaty
    Hi,

    On "DB2 v8.1 fp2 for Windows 2000" I would like to execute SQL statements from DB2 Command Window with parameter 'my_table_name'?

    Sample
    script_name my_table_name

    Old fashion way
    Now I have to open SQL file, change 'my_table_name' to table name and then execute it at DB2 Command Window. To do all this tasks over and over is very time consuming. Is it any way to do this from Command Window? It can be with batch or without batch file. Just giving me some idea would be very usefull to me.

    I have folowing SQL:
    SELECT
    SUBSTR(A.TBCREATOR,1,20) AS TABSCHEMA,
    SUBSTR(A.TBNAME,1,20) AS TABNAME,
    SUBSTR(A.COLNAME,1,20) AS COLNAME,
    SUBSTR(A.CONSTNAME,1,18) AS CONSTNAME
    FROM
    SYSIBM.SYSKEYCOLUSE A,
    SYSIBM.SYSTABCONST B
    WHERE
    A.CONSTNAME = B.NAME
    AND B.CONSTRAINTYP='P'
    AND A.TBCREATOR = 'my_table_name'

    Thanks,
    Grofaty
    You could create a batch file, say "grofaty.cmd" containing the following:

    db2 connect to .... user ... using ....
    db2 select substr.... from ... where ... a.tbcreator='%1'

    and then call it:

    c:\> grofaty.cmd your_table_name

    The variable %1 will be substituted with the batch file parameter.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    Thank you very much. It works for me. Excelent idea!

    Thanks,
    Grofaty

Posting Permissions

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