[7.4.6] Escaping strings in text arrays passed through JDBC?

Поиск
Список
Период
Сортировка
От Eli Bingham
Тема [7.4.6] Escaping strings in text arrays passed through JDBC?
Дата
Msg-id 4D818F9B-4FD4-11D9-A381-000D932A4B80@savagebeast.com
обсуждение исходный текст
Ответы Re: [7.4.6] Escaping strings in text arrays passed through
Список pgsql-jdbc
Hi folks,

The list was extremely helpful on my last bit of esoterica, so I
thought that I'd ask something else that is holding me up.

Imagine a PLpgSQL function defined as:

CREATE OR REPLACE FUNCTION do_stuff (text[])
RETURNS INTEGER
AS
'
[... do stuff ...]
' LANGUAGE pgplsql;

I need to call this function via a CallableStatement in JDBC.  I know
that you can set that up like:

CallableStatement stmt = conn.prepareCall ("{ ? = call do_stuff
(?::text[]) }";
stmt.registerOutParameter (1, Types.INTEGER);
stmt.setObject (2, "{x, y, z}")

But what can I do when one of the input strings x, y, or z has a comma
in it?  How can I escape the comma so that the stored procedure will
still see a text array of three elements?

Thanks!

Eli Bingham
SavageBeast Technologies


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

Предыдущее
От: "Xavier Poinsard"
Дата:
Сообщение: Patch to reduce the number of messages to translate
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: [7.4.6] Escaping strings in text arrays passed through