pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to get the SQL query from a PreparedStatement?
3+ messages / 2 participants
[nested] [flat]

* How to get the SQL query from a PreparedStatement?
@ 2007-11-06 02:19 Andres Olarte <olarte.andres@gmail.com>
  2007-11-06 07:45 ` Re: How to get the SQL query from a PreparedStatement? Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Andres Olarte @ 2007-11-06 02:19 UTC (permalink / raw)
  To: pgsql-jdbc

Hi!

Is it possible to get the query string (including the formatted
parameters) from a PreparedStatement?

The idea is to get the query text, to send it into an stored procedure
to be executed within the sp (with some other stuff).  This is an idea
I had to simulate variable parameter lists in stored procs.  Is it
possible?

Thanks in advance,

Andres



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to get the SQL query from a PreparedStatement?
  2007-11-06 02:19 How to get the SQL query from a PreparedStatement? Andres Olarte <olarte.andres@gmail.com>
@ 2007-11-06 07:45 ` Oliver Jowett <oliver@opencloud.com>
  2007-11-11 17:46   ` Re: How to get the SQL query from a PreparedStatement? Andres Olarte <olarte.andres@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliver Jowett @ 2007-11-06 07:45 UTC (permalink / raw)
  To: Andres Olarte <olarte.andres@gmail.com>; +Cc: pgsql-jdbc

Andres Olarte wrote:

> Is it possible to get the query string (including the formatted
> parameters) from a PreparedStatement?

In general you can't because the query's not sent like that (the 
parameter values are sent out of line from the query).

IIRC, PreparedStatement.toString() will give you an approximation, but 
I'm not sure how accurate the results are (and it's not part of the spec)

-O



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to get the SQL query from a PreparedStatement?
  2007-11-06 02:19 How to get the SQL query from a PreparedStatement? Andres Olarte <olarte.andres@gmail.com>
  2007-11-06 07:45 ` Re: How to get the SQL query from a PreparedStatement? Oliver Jowett <oliver@opencloud.com>
@ 2007-11-11 17:46   ` Andres Olarte <olarte.andres@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Andres Olarte @ 2007-11-11 17:46 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Then, is it possible to use the driver just to format the parameters
into the PG format?  My guess is that it should be done somewhere, for
example when using setXXX methods.  But I haven't looked deep enough
in the source.  Would it be possible to use this functionality so I
don't have to reinvent the wheel?

On Nov 6, 2007 1:45 AM, Oliver Jowett <oliver@opencloud.com> wrote:
> Andres Olarte wrote:
>
> > Is it possible to get the query string (including the formatted
> > parameters) from a PreparedStatement?
>
> In general you can't because the query's not sent like that (the
> parameter values are sent out of line from the query).
>
> IIRC, PreparedStatement.toString() will give you an approximation, but
> I'm not sure how accurate the results are (and it's not part of the spec)
>
> -O
>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-11-11 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-06 02:19 How to get the SQL query from a PreparedStatement? Andres Olarte <olarte.andres@gmail.com>
2007-11-06 07:45 ` Oliver Jowett <oliver@opencloud.com>
2007-11-11 17:46   ` Andres Olarte <olarte.andres@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox