Subject | Activating and de-activating triggers in SP |
---|---|
Author | Sudheer Palaparambil |
Post date | 2005-12-06T04:24:22Z |
Hi,
Can I have a SP like this ? I don't want to fire the 'after insert
trigger'
on table instant_purchase for this particular insert. Is it safe ?
Thank you.
Sudheer Palaparambil
/--------------------------------
CREATE PROCEDURE INSTANT_PURCHASE_SPLIT_UPDATE1(
COMPANY_ID SMALLINT,
OLD_ID INTEGER,
NEW_ID INTEGER,
QUANTITY INTEGER)
AS
BEGIN
UPDATE rdb$triggers SET rdb$trigger_inactive = 1
WHERE ( rdb$trigger_name = 'TR_INSTANT_PURCHASE_AI' );
INSERT INTO instant_purchase ( company_id, id, product_id, isbn,
quantity,
currency_id, exchange_rate, rate )
SELECT :company_id, :new_id, product_id, isbn, :quantity,
currency_id,
exchange_rate, rate
FROM instant_purchase
WHERE ( company_id = :company_id ) AND ( id = :old_id );
UPDATE rdb$triggers SET rdb$trigger_inactive = 0
WHERE ( rdb$trigger_name = 'TR_INSTANT_PURCHASE_AI' );
EXIT;
END
/--------------------------------
Can I have a SP like this ? I don't want to fire the 'after insert
trigger'
on table instant_purchase for this particular insert. Is it safe ?
Thank you.
Sudheer Palaparambil
/--------------------------------
CREATE PROCEDURE INSTANT_PURCHASE_SPLIT_UPDATE1(
COMPANY_ID SMALLINT,
OLD_ID INTEGER,
NEW_ID INTEGER,
QUANTITY INTEGER)
AS
BEGIN
UPDATE rdb$triggers SET rdb$trigger_inactive = 1
WHERE ( rdb$trigger_name = 'TR_INSTANT_PURCHASE_AI' );
INSERT INTO instant_purchase ( company_id, id, product_id, isbn,
quantity,
currency_id, exchange_rate, rate )
SELECT :company_id, :new_id, product_id, isbn, :quantity,
currency_id,
exchange_rate, rate
FROM instant_purchase
WHERE ( company_id = :company_id ) AND ( id = :old_id );
UPDATE rdb$triggers SET rdb$trigger_inactive = 0
WHERE ( rdb$trigger_name = 'TR_INSTANT_PURCHASE_AI' );
EXIT;
END
/--------------------------------