Subject Re: [firebird-support] REPLACE command
Author Milan Babuskov
Martijn Tonies wrote:
>>>Is there a REPLACE command avaible at Firebird? With the same function
>
> Like in mySQL:
>
>>No but you can write a simple BEFORE INSERT trigger to do the same
>>thing, and it would be a much standard way.
>
> I'm not sure if I understand how a BEFORE INSERT trigger comes into the
> picture?

CREATE TRIGGER ... BEFORE INSERT ...
AS
IF EXISTS (SELECT * FROM TABLE WHERE PK = NEW_PKVALUE) THEN
DELETE FROM TABLE WHERE PK = NEW_PKVALUE;

And that's all. I know the syntax isn't 100% correct, but you get the
point. Of course, if you don't want it to work that way all the time,
you can write also simple stored procedure to do it.

--
Milan Babuskov
http://fbexport.sourceforge.net