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 > Execute SQL's from Command Windows with parameter my_table_name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-13-03, 14:26
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
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 14:31.
Reply With Quote
  #2 (permalink)  
Old 11-13-03, 16:59
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: Execute SQL's from Command Windows with parameter my_table_name

Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 11-14-03, 01:40
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,

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

Thanks,
Grofaty
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