Обсуждение: PreparedStatement syntax extensions?
First off, I'm pretty much a noob with anything but very basic SQL and JDBC, so apologies in advance if these are stupid questions ... I am using the "WHERE foo = ANY (?)" syntax for my PreparedStatements to avoid dynamically creating gigantic "IN (?, ?, ...)" statements. After much searching, I found it syntax in this thread: http://archives.postgresql.org/pgsql-jdbc/2011-04/msg00019.php With all of my Google-fu, I have been unable to find any other mention of this syntax anywhere else on the Interwebs, which brings me to question #1: Is this construct documented anywhere? A follow-up post contains this PreparedStatement syntax: SELECT ?::int[] Is this specifying a type for the PreparedStatement parameter? If not, what is it doing? And again, is there any documentation of this syntax? Thanks! -- ======================================================================== Ian Pilcher arequipeno@gmail.com "If you're going to shift my paradigm ... at least buy me dinner first." ========================================================================
> Is this construct documented anywhere?
http://www.postgresql.org/docs/current/static/functions-comparisons.html
> SELECT ?::int[]
>
>Is this specifying a type for the PreparedStatement parameter? If not,
>what is it doing?
>
>And again, is there any documentation of this syntax?
it's just casting to int[] (slightly different idea than specifying it as a type, but not a terribly important distinction here). That particular syntax is noted under CREATE CAST ( http://www.postgresql.org/docs/current/static/sql-createcast.html ); not sure if casting in general has its own separate section.
---
Maciek Sakrejda | System Architect | Truviso
1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com
http://www.postgresql.org/docs/current/static/functions-comparisons.html
> SELECT ?::int[]
>
>Is this specifying a type for the PreparedStatement parameter? If not,
>what is it doing?
>
>And again, is there any documentation of this syntax?
it's just casting to int[] (slightly different idea than specifying it as a type, but not a terribly important distinction here). That particular syntax is noted under CREATE CAST ( http://www.postgresql.org/docs/current/static/sql-createcast.html ); not sure if casting in general has its own separate section.
---
Maciek Sakrejda | System Architect | Truviso
1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com
On 08/26/2011 11:49 AM, Maciek Sakrejda wrote: >> Is this construct documented anywhere? > > http://www.postgresql.org/docs/current/static/functions-comparisons.html > >> >>And again, is there any documentation of this syntax? > > http://www.postgresql.org/docs/current/static/sql-createcast.html ); not > sure if casting in general has its own separate section. Thank you! -- ======================================================================== Ian Pilcher arequipeno@gmail.com "If you're going to shift my paradigm ... at least buy me dinner first." ========================================================================