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

From: Eli Bingham <eli(at)savagebeast(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [7.4.6] Escaping strings in text arrays passed through JDBC?
Date: 2004-12-17 02:35:23
Message-ID: 4D818F9B-4FD4-11D9-A381-000D932A4B80@savagebeast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-12-17 02:57:01 Re: [7.4.6] Escaping strings in text arrays passed through
Previous Message Xavier Poinsard 2004-12-16 23:07:18 Patch to reduce the number of messages to translate