parse error at or near $1

From: Michael McDonnell <michael(at)winterstorm(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: parse error at or near $1
Date: 2001-04-16 21:33:49
Message-ID: 3ADB653D.DEB92055@winterstorm.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2001-04-16 22:34:29 7.0.3 ==> 7.1
Previous Message Calvin Dodge 2001-04-16 21:19:23 Re: Driver ODBC postdrv.exe fails on 7.1