RE: [GENERAL] PL/pgSQL syntax/usage question
От | Stephane FILLON |
---|---|
Тема | RE: [GENERAL] PL/pgSQL syntax/usage question |
Дата | |
Msg-id | 01BF6E73.81133FC0.fillons@offratel.nc обсуждение исходный текст |
Список | pgsql-general |
> -----Message d'origine----- > De: Henk van Lingen [SMTP:henkvl@cs.uu.nl] > Date: mercredi 2 fevrier 2000 01:57 > A: pgsql-general@hub.org > Objet: [GENERAL] PL/pgSQL syntax/usage question > > Hi *, > > I'm starting with PL/pgSQL but can't exactly find out how to do > something like this: > > CREATE FUNCTION textkey (text, int4) RETURNS text AS ' > DECLARE > tabel ALIAS FOR $1; > id ALIAS FOR $2; > result record; > BEGIN > select lname into result from tabel > where person_id=id; > return result; > END; > ' LANGUAGE 'plpgsql'; > > csbase=> select textkey ('person',111) as result; > ERROR: parser: parse error at or near "$1" > > postmaster.log: > > StartTransactionCommand > query: select textkey ('person',111) as result; > ProcessQuery > query: SELECT lname from $1 where person_id=$2 > ERROR: parser: parse error at or near "$1" > DEBUG: Last error occured while executing PL/pgSQL function textkey > DEBUG: line 6 at select into variables > AbortCurrentTransaction > Replace the line "where person_id=id" with "where person_id = id". Add a space between = and id as PL/pgSQL trie to interpret the operator =$2 that doesn't exist. Regards, Stephane FILLON
В списке pgsql-general по дате отправления: