[7.4.6] Escaping strings in text arrays passed through JDBC? - Mailing list pgsql-jdbc

From Eli Bingham
Subject [7.4.6] Escaping strings in text arrays passed through JDBC?
Date
Msg-id 4D818F9B-4FD4-11D9-A381-000D932A4B80@savagebeast.com
Whole thread Raw
Responses Re: [7.4.6] Escaping strings in text arrays passed through  (Kris Jurka <books@ejurka.com>)
List 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 by date:

Previous
From: "Xavier Poinsard"
Date:
Subject: Patch to reduce the number of messages to translate
Next
From: Kris Jurka
Date:
Subject: Re: [7.4.6] Escaping strings in text arrays passed through