user6519393
user6519393

Reputation:

Error oracle sql developer "SQL command not properly ended"

I am getting this error using oracle sql developer for the query below and can't really figure out what is wrong with it. "SQL command not properly ended"

select * from Table1 FETCH FIRST ROW ONLY

Upvotes: 8

Views: 11361

Answers (2)

MikeKulls
MikeKulls

Reputation: 1006

After 5 years this question doesn't have a full answer except what is in the comments. Credit to @mathguy for the answer. You can do this

SELECT * from Table1 WHERE ROWNUM = 1

OR

SELECT * FROM Table1 WHERE ROWNUM < 10

These will give essentially random rows but generally this is just used for data exploration anyway, so not a big deal. If you want one specific row then use something like this:

WITH X AS (
  SELECT *, ROW_NUMBER() OVER (ORDER BY SomeField) FROM table1
)
SELECT * FROM X WHERE RN = 1`

Upvotes: 5

user5683823
user5683823

Reputation:

What version of Oracle are you using? FETCH (...) is only available in Oracle 12.

Please run this statement and see what it tells you:

SELECT * FROM v$version WHERE banner LIKE 'Oracle%'; 

Upvotes: 26

Related Questions