From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | Brady S Edwards <brady(dot)s(dot)edwards(at)seagate(dot)com> |
Cc: | "[JDBC]" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: JDBC parameter binding not working for PL/PGSQL block JDBC3 Version 9.0-801 |
Date: | 2011-04-27 23:17:20 |
Message-ID: | BANLkTinDqx+SMtEy9siJhfRtxwxawHb5Eg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On 28 April 2011 08:40, Brady S Edwards <brady(dot)s(dot)edwards(at)seagate(dot)com> wrote:
> Thank you for your reply Oliver.
>
> Is it possible to call an anonymous plpgsql block with bind variables?
> With Oracle I would just prepare a statement like:
> declare
> ...
> begin
> xx = ?;
> ...
> end;
>
> These are created on the fly, so I can't really create stored
> procedures for them.
Looking at the description of DO, I don't see a way to provide parameters:
> The code block is treated as though it were the body of a function with no parameters, returning void. It is parsed and executed a single time.
If the body of the block is used just once, then it may be simplest to
just interpolate the parameter values into the block body yourself
while generating it.
If you're going to reuse the block with different values, though, it's
probably worthwhile creating a proper function, even if you turn
around and drop it later. (You could perhaps create it in the pg_temp
schema)
If you don't have explicit reuse of these statements but the same
generated block is likely to be generated again later, you could do
something like a per-connection cache of function text to temporary
function definition.
Oliver
From | Date | Subject | |
---|---|---|---|
Next Message | Lew | 2011-04-28 02:10:43 | Re: O/T: Class.forName(driver) repeatedly? [Was: JDBC parameter binding not working for PL/PGSQL block JDBC3 Version 9.0-801] |
Previous Message | Brady S Edwards | 2011-04-27 22:44:52 | Re: O/T: Class.forName(driver) repeatedly? [Was: JDBC parameter binding not working for PL/PGSQL block JDBC3 Version 9.0-801] |