Michael McDonnell <michael@winterstorm.ca> writes:
> And when I run "SELECT contactable_name(1);" I get the error message
> "parse error at or near $1".
$1 is a parameter placeholder; probably your problem is unexpected
substitution (or lack of substitution) of a plplgsql variable or
parameter into a query that's being sent to the underlying SQL engine.
In 7.1 the easiest way to debug this type of problem is to do
SET debug_print_query TO 1;
then execute the problem function call, and then look in the postmaster
log to see what queries got generated by the function. In older PG
versions there is no debug_print_query variable, so you have to resort
to setting environment variable PGOPTIONS to "-d2" before starting psql
to get query logging.
plpgsql needs more support for debugging --- some kind of trace
mechanism that doesn't require access to the postmaster log would be
awfully nice ...
regards, tom lane