Saturday, October 21, 2017

select * from emp where rownum<=1 gives one record....but select * from emp where rownum=2 or any number doesn't give any records..what's the reason

select * from emp where rownum<=1 gives one record....but 
select * from emp where rownum=2 or any number doesn't give any records..what's the reason
--------------------------------------------------------------------------------------------------------
A ROWNUM is not data in the database or table. It has no relationship to anything in the database, including tables, tablespaces, data files, or to the order in which a row is inserted into a table. 

ROWNUM returns a number indicating the order in which Oracle select the row from the table. The first row has rownum 1, the second 2 etc.......

Here If row is fetched then ROWNUM will generate at runtime,As ROWNUM is a Pseudo Column, it generates values at runtime of the Query.

SO HERE --> the first row fetched has rownum 1, and makes the where condition false. The next row, the second, is now the first row and has rownum 1, and makes the where condition false..

No comments:

Post a Comment

SupplierAddressImportTemplate.xlsm South Africa Suburb Field mapping in POZ_SUPPLIER_ADDRESSES_INT

Suburb mpping in Supplier Address Import Template will be mapped to Address Element Attribute2 (HZ_LOCATIONS. ADDR_ELEMENT_ATTRIBUTE2)