简体   繁体   中英

While compiling trigger in Oracle SQL throwing error as table or view doesn't exist

Also following error coming near "declare @empsal" as PLS-00103 :Encountered the symbol "@" when expecting one of the following ...

My tables do exist in the database.

My trigger:

create or replace
TRIGGER leavemastertrg After INSERT 
ON "xyz"."leave_master"
    declare @empid int;
    declare @empname varchar(100);
    declare @empsal decimal(10,2);
    declare @audit_action varchar(100);

    select @empid=i.LEAVE_ID from inserted i;   
    select @empname=i.LEAVE_NAME from inserted i;   
    select @empsal=i.LEAVE_STATUS from inserted i;  
    set @audit_action='Inserted Record -- After Insert Trigger.';

    insert into manager_master
           (MANAGER_ID,MANAGER_NAME,MANAGER_STATUS,MANAGER_AUDIT_ACTION,MANAGER_AUDIT_TIMESTAMP) 
    values(@empid,@empname,@empsal,@audit_action,getdate());

    PRINT 'AFTER INSERT trigger fired.'
GO

CREATE OR REPLACE TRIGGER LM_AFTER_INSERT AFTER INSERT ON LEAVE_MASTER FOR EACH ROW

DECLARE v_username varchar2(20 byte);

BEGIN SELECT user INTO v_username FROM dual;

INSERT INTO manager_master
( MANAGER_ID,
 MANAGER_NAME,
 MANAGER_STATUS,
 Modified_by)
VALUES
( :new.LEAVE_ID,
  :new.LEAVE_NAME,
  :new.LEAVE_STATUS,
  user);

END;

This sample code working fine in Oracle SQL.Wrong way i applied Mysql,oralce sql concepts.Thanks to all.

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