8

Given a working example in T-SQL:

SELECT *, ROW_NUMBER() OVER (ORDER BY name ) as row_id
 FROM 
[schemaName].[Zoo]

If I keep * selector it throws following error ORA-00923: FROM keyword not found where expected.

Is there a way to keep * selector, and make it work in oracle pl/sql? (currently I could achieve wanted result only by mentioning all column names)

meta4
  • 788
  • 1
  • 10
  • 24
  • 1
    What's this got to do with plsql? If nothing, please remove from tag list. Thanks! –  Jul 25 '16 at 12:05

2 Answers2

13

Try this:

SELECT a.*, ROW_NUMBER() OVER (ORDER BY name ) as row_id FROM schemaName.Zoo a

Here a is alias for table schemaName.Zoo. This will generate all columns from the original table, with row_id column added at the end.

Sanjay Radadiya
  • 1,254
  • 15
  • 22
3

Use SELECT t.*, ROW_NUMBER ... FROM tablename t;

nilsman
  • 346
  • 1
  • 9