Only wanted to indicate further that I know that IF loop is bad logic
in itself, where oper will get overwritten in each case. I've now got
the following instead:
CREATE FUNCTION online_pct_trig() RETURNS opaque AS '
DECLARE
i1hr timestamp;i1day timestamp;i1wk timestamp;i1mo timestamp;i1yr timestamp;
oper varchar;
BEGIN
SELECT o.isodt1hr INTO i1hr, o.isodt1day INTO i1day, o.isodt1wk INTO i1wk, o.isodt1mo INTO i1mo,
o.isodt1yrINTO i1yrFROM online_pct oWHERE o.id = NEW.id;
IF i1hr <= (now() - ''00:01''::interval) THEN oper := ''SELECT online_pct_func(NEW.id, '';oper := oper || ''01:00'' ||
'');'';EXECUTEoper;END IF;IF i1day < (now() - ''01:00''::interval)THEN oper := ''SELECT online_pct_func(NEW.id, '';oper
:=oper || ''1 day'' || '');'';EXECUTE oper;END IF;IF i1wk < (now() = ''1 day''::interval)THEN oper := ''SELECT
online_pct_func(NEW.id,'';oper := oper || ''1 week'' || '');'';EXECUTE oper;END IF;IF i1mo < (now() - ''1
week''::interval)THENoper := ''SELECT online_pct_func(NEW.id, '';oper := oper || ''1 mon'' || '');'';EXECUTE oper;END
IF;IFi1yr < (now() - ''1 mon''::interval)THEN oper := ''SELECT online_pct_func(NEW.id, '';oper := oper || ''1 year'' ||
'');'';EXECUTEoper;END IF;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER online_pct_trig
AFTER INSERT ON info
FOR EACH ROW EXECUTE PROCEDURE online_pct_trig();
I get no errors when I create it; but it isn't invoking the function
either - that's what the issue is, but I'm not certain why or what
I've got to correct in order to get it to work. Thank for any input..
- Oeln