db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: precompile statement with result offset and fetch first clauses
Date Thu, 04 Feb 2010 12:43:27 GMT
On04.02.10 13:23, Burk Mayer wrote:
> hi,
>
> i'm getting an error while precompiling a prepared statement with offset and
> fetch first clauses.
>
> the documentation (
> http://db.apache.org/derby/docs/dev/ref/rrefsqljoffsetfetch.html#rrefsqljoffsetfetch)<http://db.apache.org/derby/docs/dev/ref/rrefsqljoffsetfetch.html#rrefsqljoffsetfetch>,
> provides following example*:
> *
>
> *SELECT * FROM T ORDER BY I OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY*
>
> the prepared statement looks like:
>
> *Connection con = datasource.getConnection();
> PreparedStatement p = con.prepareStatement("**SELECT * FROM T ORDER BY
> I OFFSET ? ROWS FETCH NEXT ? ROWS ONLY**");
> ***
>
> but an SQLException is thrown: Syntax error: Encountered "?" at line 1,
> column 60.
>
>    

Hi Burk,

According to DERBY-4208 [1], this feature was added to Derby 10.6 (or 
trunk, the development branch). As far as I can see, it hasn't been 
back-ported to the 10.5 branch, so I think you have to wait until 10.6 
is out before you can use parameters with OFFSET and/or FETCH.


Regards,
-- 
Kristian

[1] https://issues.apache.org/jira/browse/DERBY-4208

> i'm using following version of derby:
> Bundle-Name: Apache Derby 10.5
> Bundle-Version: 10.5.3000000.802917
>
> the connection is created from a container-managed connection-pool
> datasource:
>
>       <Resource
>         name="jdbc/prototype"
>         auth="Container"
>         type="javax.sql.DataSource"
>         driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
>         url="jdbc:derby:memory:prototype;create=true"
>         username=""
>         password=""
>         maxActive="10"
>         maxIdle="5"
>         maxWait="10000"
>       />
>
> thank you for your support,
> burk
>
>    


Mime
View raw message