Re: SQL function problem in 7.1?
От | Stephan Szabo |
---|---|
Тема | Re: SQL function problem in 7.1? |
Дата | |
Msg-id | Pine.BSF.4.21.0102090941430.59316-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | SQL function problem in 7.1? ("Richard Huxton" <dev@archonet.com>) |
Список | pgsql-general |
You don't want to quote the $1. Otherwise you're going to probably get the literal '$1'. create function foob(text) returns int as 'select a from foo where b = $1;' language'sql'; (the space before the $ is significant) Stephan Szabo sszabo@bigpanda.com On Fri, 9 Feb 2001, Richard Huxton wrote: > Am I doing something stupid with strings in SQL functions. > > > richardh=> select version(); > version > ------------------------------------------------------------------------ > PostgreSQL 7.1beta3 on i586-pc-linux-gnu, compiled by GCC egcs-2.91.66 > (1 row) > > richardh=> select * from foo; > a | b > ---+----- > 1 | aaa > 2 | bbb > 3 | ccc > (3 rows) > > richardh=> create function fooa(int) returns text as 'select b from foo > where a = $1;' language 'sql'; > CREATE > richardh=> select fooa(2); > fooa > ------ > bbb > (1 row) > > richardh=> create function foob(text) returns int as 'select a from foo > where b = ''$1'';' language 'sql'; > CREATE > richardh=> select foob('bbb'); > foob > ------ > > (1 row) > > > TIA > > - Richard Huxton >
В списке pgsql-general по дате отправления: