error on last line of function

From: Matthew Nuzum <cobalt(at)bearfruit(dot)org>
To: Postgres General List <pgsql-general(at)postgresql(dot)org>
Subject: error on last line of function
Date: 2002-11-23 03:38:02
Message-ID: 1038022685.3524.102.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello, I'm debugging a trigger that isn't working. It's supposed to run
the function delete_page() after a delete on table "pages". It's
producing the error:
# delete from pages where pageid=3550;
NOTICE: plpgsql: ERROR during compile of delete_page near line 81
ERROR: parse error at or near ";"

Line 81 is the last line of the function and merely says: END;

Maybe some fresh sets of eyes can give me some help with this? Here is
the function, any help is appreciated...

DECLARE
temp record;
BEGIN
IF old.page_type = ''f''
THEN
IF old.ftr_type = ''adf''
THEN
-- adf features store id in ftr_data
SELECT INTO temp delete_adf(old.ftr_data);
ELSE IF old.ftr_type = ''cal''
THEN
-- cal features do not store id in ftr_data
-- get the id
SELECT INTO temp * FROM ftr_cal_calendar
WHERE accountid = old.accountid AND name = substr(old.path,2);
SELECT INTO temp delete_cal(temp.calendarid);
ELSE IF old.ftr_type = ''cyu''
THEN
-- cyu stores id in ftr_data
SELECT INTO temp delete_cyu(old.ftr_data);
ELSE IF old.ftr_type = ''fa2'' OR old.ftr_type = ''faq''
THEN
-- these store id in ftr_data
SELECT INTO temp delete_faq(old.ftr_data);
ELSE IF old.ftr_type = ''fdl''
THEN
-- fdl features do not store id in ftr_data
-- get the id
SELECT INTO temp * FROM ftr_fdl
WHERE accountid = old.accountid AND name = substr(old.path,2);
SELECT INTO temp delete_fdl(temp.fdlid);
ELSE IF old.ftr_type = ''frm''
THEN
-- frm features do not store id in ftr_data
-- get the id
SELECT INTO temp * FROM ftr_frm
WHERE accountid = old.accountid AND name = substr(old.path,2);
SELECT INTO temp delete_frm(temp.id);
ELSE IF old.ftr_type = ''gal''
THEN
-- galeries do not store id in ftr_data
-- get the id
SELECT INTO temp * FROM ftr_gal
WHERE accountid = old.accountid AND name = substr(old.path, 2);
SELECT INTO temp delete_gal(temp.galleryid);
ELSE IF old.ftr_type = ''htm''
THEN
-- these store id in ftr_data
SELECT INTO temp delete_htm(old.ftr_data);
ELSE IF old.ftr_type = ''mbo''
THEN
-- these use a combination of ftr_data
-- and accountid. Deleting all matching records
DELETE FROM ftr_mbo_members
WHERE accountid = old.accountid AND realm = old.ftr_data;
ELSE IF old.ftr_type = ''rfl''
THEN
-- these store id in ftr_data
SELECT INTO temp delete_rfl(old.ftr_data);
ELSE IF old.ftr_type = ''shp''
THEN
-- these do not store the id in ftr_data
SELECT INTO temp "ID" as id FROM ftr_shp
WHERE accountid = old.accountid AND cartname = substr(old.path,
2);
SELECT INTO temp delete_shp(temp.id);
ELSE IF old.ftr_type = ''sta''
THEN
-- these do not store the id in ftr_data
SELECT INTO temp * FROM ftr_sta_directories
WHERE accountid = old.accountid and name = substr(old.path, 2);
SELECT INTO temp delete_sta(temp.staffid);
ELSE IF old.ftr_type = ''stm''
THEN
-- these do not store the id in ftr_data
SELECT INTO temp * FROM ftr_stm
WHERE accountid = old.accountid AND name = substr(old.path, 2);
SELECT INTO temp delete_stm(temp.stmid);
END IF;
END IF;
RETURN old;
END;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Berkus 2002-11-23 04:43:39 Hung Postgres Processes
Previous Message Romel Tarin 2002-11-23 02:59:32 trigger function