• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

oracle number or rows returned

does anyone know how to get the number of records returned from a select query the usual things like ocirowcount only tell you the number of affected rows in an update query etc not in a select query

0
andrew67
Asked:
andrew67
  • 3
  • 2
1 Solution
 
hernst42Commented:
You will only get the number after you fetched all neccesary records (but then you could count the rows also :-( )
I don't know of any method that can do this efficient without running the query twice.

$rows =  Select count(*) from (<your SQL-Statement>) (so it is emulated in pear DB)

See:
http://de2.php.net/ocirowcount
0
 
minichickenCommented:
this?

$rows = ora_numrows (resource cursor)
0
 
minichickenCommented:
$rows = ora_numrows ($put_your_resource_cursor_here);
0
 
hernst42Commented:
@minichicken
The ora_numrows will only tell you how many rows you have fetched already. You will only get the correct result after you fetched all records. If you fetched 5 record ora_numrows will return 5, after you fetch another 5 rows it will return 10, ...

the Oracle 7 - functions should no longer be used as they are not realy supported and as andrew67 stated hi is aready using the oci8 interface (ocirowcount)
0
 
minichickenCommented:
hmm... alright, thanks for the info :)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now