CREATE VIEW (dynamically)

From: Emmanuel Engelhart <"Emmanuel Engelhart"(at)postgresql(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Cc: emmanuel(dot)engelhart(at)epita(dot)fr
Subject: CREATE VIEW (dynamically)
Date: 2002-11-09 14:52:11
Message-ID: 20021109145211.260cb84f.EmmanuelEngelhart@rack
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

code
<<
CREATE FUNCTION "requests_insert_after" () RETURNS opaque AS '
DECLARE
view_name text;
BEGIN
view_name := ''request_'' || NEW.id;
CREATE VIEW view_name AS select * from groups;
return NEW;
END' LANGUAGE 'plpgsql';

CREATE TRIGGER "requests_insert_after" AFTER INSERT ON "requests" FOR EACH ROW
EXECUTE PROCEDURE "requests_insert_after" ();>>

This code after an insertion on table "requests" give me this message :
<<
PostgreSQL said: ERROR: parser: parse error at or near "$1"
>>

Why ?

Thx for any help.

Emmanuel Engelhart

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2002-11-09 15:52:32 Re: Time difference without intervals
Previous Message karthick v 2002-11-09 05:30:06 Output of function into a file