简体   繁体   中英

After insert trigger in postgres not working

i am creating a trigger that is supposed to be fired every time a new device is added in to the device table. Since the id in the table is auto incrementing i have set is so that the trigger is fired after the insert. The insertion works but the trigger is not being fired or atleast i am not seeing the data in the table that is supposed to receive the information.

the function

CREATE OR REPLACE function insertstagingdevice() returns trigger as $device$

DECLARE
    begin
           INSERT INTO postgres.staging_import_remote_access.device(device_id,
                                                                     name, eui,
             
                                                                     location)
            VALUES(new.id,
                new.name,
                new.eui,
                new.location);
            RETURN NEW;
    END
$device$ language plpgsql;

The trigger

CREATE TRIGGER insertionIntoDevice
    after INSERT
    ON postgres.public.device
    FOR EACH row
    EXECUTE PROCEDURE insertstagingdevice();

Is there something i am overseeing?

The code is correct. there was an error elswehere. Thanks for your help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM