parse error at or near $1 - Mailing list pgsql-general

From Michael McDonnell
Subject parse error at or near $1
Date
Msg-id 3ADB653D.DEB92055@winterstorm.ca
Whole thread Raw
Responses Re: parse error at or near $1
List pgsql-general
I have created the following pl/pgsql function:

     CREATE FUNCTION contactable_name (integer) RETURNS text AS '
       DECLARE
         myid ALIAS FOR $1;
         contact_table text;
       BEGIN
         SELECT INTO contact_table t.table_name FROM contactable c,
     contactable_type t WHERE c.id = $1 AND c.type_id = t.id;
         RETURN EXECUTE contact_table || ''_name('' || myid ||
     '')'';
       END;
     ' LANGUAGE 'plpgsql';

And when I run "SELECT contactable_name(1);" I get the error message
"parse error at or near $1".

The purpose of this function is to return the output of another
function.  It dynamically builds the function name based on the name of
the table corresponding to the type of thing it is building the name
for.

--
MM


pgsql-general by date:

Previous
From: "Bob McCormick"
Date:
Subject: Schema Import
Next
From: "Firestar"
Date:
Subject: Inserting Unicode into Postgre