By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,288 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,288 IT Pros & Developers. It's quick & easy.

Copying triggers

P: n/a
Hi

I m new to DB2, Please bear with me if this is silly question, but i
need to know how to copy(only triggers) 400 triggers from one data
base to another on same server and also onto different server.
we use 8.1 on aix.

thanks
rik

Feb 7 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"rick" <ka*******@gmail.comwrote in message
news:11**********************@k78g2000cwa.googlegr oups.com...
Hi

I m new to DB2, Please bear with me if this is silly question, but i
need to know how to copy(only triggers) 400 triggers from one data
base to another on same server and also onto different server.
we use 8.1 on aix.

thanks
rik
You can use the db2look utility to pull the DDL. You may have to pull the
entire database DDL, but the triggers will be grouped together in the
output. See the Command Reference manual.

The bad news is that you will have replace the last semi-colon in each
trigger with a different termination character (such as @) because triggers
use the semi-colon for terminating certain statements within the trigger.
Then you will have to run the script as follows:

db2 -td@ -vf script-name output

However, if you have a tool like DBArtisan, it is smart enough to know when
the trigger terminates and you can just run the script unmodified with ISQL.
Feb 7 '07 #2

P: n/a
On Feb 7, 4:25 am, "rick" <kantha...@gmail.comwrote:
Hi

I m new to DB2, Please bear with me if this is silly question, but i
need to know how to copy(only triggers) 400 triggers from one data
base to another on same server and also onto different server.
we use 8.1 on aix.

thanks
rik
Not tested, but I figure it should work

db2 connect to <source db>
db2 -x "select text || ' @' from syscat.triggers" | tee
my_triggers.ddl
db2 connect to <target db>
db2 -td@ -f triggers.ddl

if you want triggers from specific schema or some other condition you
can add it in the where clause.
Feb 7 '07 #3

P: n/a
On Feb 7, 1:13 am, "Lennart" <Erik.Lennart.Jons...@gmail.comwrote:
On Feb 7, 4:25 am, "rick" <kantha...@gmail.comwrote:
Hi
I m new to DB2, Please bear with me if this is silly question, but i
need to know how to copy(only triggers) 400 triggers from one data
base to another on same server and also onto different server.
we use 8.1 on aix.
thanks
rik

Not tested, but I figure it should work

db2 connect to <source db>
db2 -x "select text || ' @' from syscat.triggers" | tee
my_triggers.ddl
db2 connect to <target db>
db2 -td@ -f triggers.ddl

if you want triggers from specific schema or some other condition you
can add it in the where clause.
Thanks Guys

I will try this out.

Feb 7 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.