MySQL Forums
Forum List  »  Other Migration

Re: how to convert sql trigger to mysql
Posted by: Peter Brawley
Date: July 15, 2022 06:35AM

You'll need separate Triggers for Insert and for Update.

No MySQL equivalent for SET ANSI_NULLS ON, SET QUOTED_IDENTIFIER ON, SET NOCOUNT ON.
.
Study the manual page for Create Trigger. You Insert Trigger will probably look something like ...

use medicavl;
drop trigger if exists coa_ins;
delimiter go
create trigger coa_ins before insert on coa for each row
begin
  if exists( select 1 from inserted i where i.coald=new.coald ) then
    set new.accounttype = if( new.openingbalance > 0, 'DR', 'CR' );
  end if;
end;
go
delimiter ;



Edited 1 time(s). Last edit at 07/15/2022 07:57AM by Peter Brawley.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: how to convert sql trigger to mysql
175
July 15, 2022 06:35AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.