I'm using oracle client in .net framework (c#) and need to limit the number of records returned in case where number of records are bigger then X
When constructing sql I understand I can append FETCH NEXT X ROWS ONLY
if I first execute the query to get the count against the sql I'm constructing and if count exceeds X I can append FETCH NEXT X ROWS ONLY
statement.
I'm curious is it possible to achieve that in one shot rather then getting the count and appending fetch next if count exceeds x
As I said in the comment, if you never display more than 300 rows, then limit to 301:
select *
from t
fetch next 301 rows only
Upon receiving the result, there are two cases:
This is pretty much a standard solution for this case.