Skip site navigation (1) Skip section navigation (2)

[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 (view raw or flat)
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

pgsql-jdbc by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group