Re: Triggers
Posted in 1998
In article <34F4BAEC.3440435D@garpac.com>, Jacob Salomon wrote: >Raj Goel wrote: >> >> I've been reading the chapters on triggers and there's something I >> don't quite understand. What I'd like to do is the following: >> >> For a given table, >> if the record exists (table has primary key), >> UPDATE the record >> else >> INSERT a new record >> >> I wrote a stored proc to do this for a single table. >> >> I need to perform this operation in 50+ tables and I keep thinking >> I need a trigger (or triggers) on each of the tables, but I can't >> figure out how to create the trigger statement. > >Raj, > >Since you need a procedure anyway, you might as well go that route - doo >all inserts and updates via this procedure that decides if it will do >the insert or the update. You can use GRANT to enforce that nobody uses >naked SQL to do inserts or updates - only the procedure. Details of >this are another story. Hmm...Any way I can write a generic procedure for insert/updating for 50+ tables which share the same structure? i.e., table1 table2 key key field1 field2 ========= << raj >> == http://www.brainlink.com/~frostbit/ ============== SYSADMIN: BrainLINK System (718) 805-6559 // http://www.brainlink.com You want to be president? Yes. Put your hand on the book and say "I Do." I Do. Fine, done. Let's eat. - G'Kar & Sheridan ============================================================================