MySQL Forums
Forum List  »  PostgreSQL

How can I convert this Postgres stored procedure to MYSQL
Posted by: Jon Bowlas
Date: February 08, 2006 07:51AM

I'm pretty new to db development but I have a requirement to create a entry versioning database, I found this postgres example of how this can be achieved easliy but I dont know how to convert to MYSQL (we're running MySQL 4.0.16) so could somebody please help me to convert it:

CREATE FUNCTION func_table1_vc ()
RETURNS OPAQUE AS '
DECLARE
v integer;
BEGIN
SELECT INTO v version FROM shadow_table1
WHERE id = OLD.id
ORDER BY version DESC LIMIT 1;
IF v ISNULL THEN
v := 0;
ELSE
v := v + 1;
END IF;
INSERT INTO shadow_table1
VALUES (OLD.id,OLD.data1,OLD.data2,v);
RETURN NEW;
END;
' LANGUAGE 'plpgsql';

Hope someone can help

Jon

Options: ReplyQuote




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.