Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Triggers

Status
Not open for further replies.

MizzGail

Technical User
Dec 4, 2002
11
0
0
US
I have never written a trigger before and I'm having problems following these wonderful manuals I have.

What I want to do is this:
On a daily basis create two new tables
create table tableA (fld1 char)
create table tableB (fld1 char)

Then I need to track new records or updates seperately.

create trigger newrecord insert on table1
for each row(insert keyfields from table1 into tableA)


create trigger update1 update of qty on table1
for each row (insert keyfields from table1 into tableB)


I'm getting syntax errors. How do I get the keyfield from table1 for each new record or updated records ?



 
MizzGail:

Given: tablea & table1 are the same structure with one column fld1 char(1).

Here's the insert trigger:

create trigger ti_table1 insert on table1
referencing new as new_record for each row
(
insert into tablea values (new_record.fld1)
);

You seem to be forgetting the referencing new string and the beginning and ending parenthesis.

I'm concerned about your comment:

-On a daily basis create two new tables

If you are dropping the two tables and recreating them daily, you'll have to recreate the triggers since they go away when you drop the table.

Regards,

Ed
 
table1 will always be resident. It is part of our ERP system.

I need to extract updates and inserts to be extracted via another process and sent to another system. I only need the key information for this other session to drive the extracts.

I will be recreating the tables that hold the extract key values due to space constraints. Most likely, since we are a 24x7 system, it will happen on sunday once a month during system maintenance. Does it make a difference if I am only keeping one fields on the tracking tables ?
 
MizzGail:

I'd say you're on the right track. It makes sense to only keep the data that's required.

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top