This is my first attempt at a plpgsql function.
Here is what I have thus far:
create function fnInsWeeks() returns integer as '
DECLARE
--theDate wedates2.wedate%TYPE;
thedate DATE;
BEGIN
SELECT INTO thedate wedate FROM wedates2 WHERE id=(SELECT MAX(id) FROM wedates2);
INSERT INTO wedates2 (wedate) VALUES (thedate+7);
return 0;
END;
' language 'sql';
It comes back at my with this:
ERROR: parser: parse error at or near "date"
Can someone please tell me what is incorrect
in the above?
Here is what I have thus far:
create function fnInsWeeks() returns integer as '
DECLARE
--theDate wedates2.wedate%TYPE;
thedate DATE;
BEGIN
SELECT INTO thedate wedate FROM wedates2 WHERE id=(SELECT MAX(id) FROM wedates2);
INSERT INTO wedates2 (wedate) VALUES (thedate+7);
return 0;
END;
' language 'sql';
It comes back at my with this:
ERROR: parser: parse error at or near "date"
Can someone please tell me what is incorrect
in the above?