Hello everybody, I desperately need documentation on MaxDB Triggers. I have the reference manual, I need something more basic with examples. I have to translate Oracle PL/SQL and PostgreSQL PL/PGSQL Triggers to MaxDB.
Here is a PL/PGSQL Trigger, if anyone has the skill and time to translate this I would be forever grateful. It is a temporal integrity constraint for a valid time table. The development of the annual salary of an employee through time in recorded. An employee identified by NAME has a SALARY for a specific period of time from START to END. The periods of time should not overlap. CREATE TRIGGER seq_key AFTER INSERT OR UPDATE ON salary FOR EACH ROW EXECUTE PROCEDURE seq_key_salary(); CREATE OR REPLACE FUNCTION seq_key_salary() RETURNS OPAQUE AS ' DECLARE VALID INTEGER; BEGIN IF ( EXISTS ( SELECT * FROM SALARY AS S1 WHERE 1 < ( SELECT COUNT(NAME) FROM SALARY AS S2 WHERE S1.NAME = S2.NAME AND (S1.START, S1.END) OVERLAPS (S2.START, S2.END) ) ) ) OR EXISTS ( SELECT * FROM SALARY AS S WHERE S.NAME IS NULL ) THEN RAISE EXCEPTION '' SEQUENCED PK CONSTRAINT VIOLATED '', NEW.NAME; END IF; RETURN NEW; END; ' LANGUAGE 'plpgsql'; -------- Table gehalt looks like this: CREATE TABLE SALARY( NAME VARCHAR, SALARY INTEGER, START DATE, END DATE, PRIMARY KEY (NAME, START) ) ------- Thank you for reading this. Alexander -- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
