Help with quote escaping in plpgsql

Поиск
Список
Период
Сортировка
От someone@arbitrary.org (Joseph)
Тема Help with quote escaping in plpgsql
Дата
Msg-id 4c8dd21a.0311141453.6c03f7d6@posting.google.com
обсуждение исходный текст
Ответы Re: Help with quote escaping in plpgsql  (Jan Wieck <JanWieck@Yahoo.com>)
Список pgsql-general
Hi,

I want to make a function that accepts a pre-formatted varchar
argument which will then be used in an IN clause:

create or replace function testing(varchar) returns int as '
declare
   int c := 0;
begin
   select count(*) from my_table where some_field in ( $1 ) into c;
   return c;
end
' language 'plpgsql';


But I can't figure out how to escape the varchar string I pass. I have
tried:

'''hello'',''world'''

and all sorts of other things.

Any suggestions?

Thanks,

Joseph

В списке pgsql-general по дате отправления:

Предыдущее
От: Christopher Browne
Дата:
Сообщение: Re: embedded postgresql
Следующее
От: Christopher Browne
Дата:
Сообщение: Re: embedded postgresql