[
https://issues.apache.org/jira/browse/DERBY-7105?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17299623#comment-17299623
]
Richard N. Hillegas commented on DERBY-7105:
--------------------------------------------
As the error message indicates, your syntax is incomplete. You are missing the
terminating ONLY keyword. Please see the syntax for the OFFSET and FETCH
clauses in the Derby Reference Manual:
https://db.apache.org/derby/docs/10.15/ref/rrefsqljoffsetfetch.html
The following script shows this behavior along with the correct syntax:
{noformat}
CONNECT 'jdbc:derby:memory:db;create=true';
CREATE TABLE t(a INT);
-- fails because the trailing ONLY keyword is absent
SELECT * FROM t FETCH FIRST ROW;
-- correct syntax
SELECT * FROM t FETCH FIRST ROW ONLY;
{noformat}
> CALLING "FETCH FIRST ROW" on an empty table will throw EOF SQL Exception
> ------------------------------------------------------------------------
>
> Key: DERBY-7105
> URL: https://issues.apache.org/jira/browse/DERBY-7105
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.14.2.0
> Environment: Windows 10
> Intellij 2020.3.2
> Reporter: Ben CHARLTON
> Priority: Minor
>
> Steps to produce
> Create derby database
>
> {code:java}
> `CREATE DATABASE APP`
>
> {code}
> Create empty table
> {code:sql}
> create table APP.PRISM_ID_MAP
> (
> MATERIAL VARCHAR(63) not null,
> STATE VARCHAR(255) not null,
> BLOCK_ID INTEGER default AUTOINCREMENT: start 1 increment 1 generated always
> as identity,
> BLOCK_SUBID INTEGER default 0 not null,
> primary key (MATERIAL, STATE),
> unique (BLOCK_ID, BLOCK_SUBID)
> ){code}
> Run a simple query
> {code:sql}
> SELECT block_id, block_subid FROM APP.prism_id_map WHERE
> PRISM_ID_MAP.MATERIAL = 'dirt'
> {code}
> Confirm Empty Set
> {code:sql}
> SELECT block_id, block_subid FROM APP.prism_id_map WHERE
> PRISM_ID_MAP.MATERIAL = 'dirt' FETCH FIRST ROW{code}
> [42X01][30000] Syntax error: Encountered "<EOF>" at line *, column *.
> This was performed using the Intellij inbuilt database schema manager.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)