Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

oracle number or rows returned

Posted on 2004-10-08
7
340 Views
Last Modified: 2013-12-12
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
Comment
Question by:andrew67
  • 3
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 125 total points
ID: 12256906
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
 
LVL 12

Expert Comment

by:minichicken
ID: 12256933
this?

$rows = ora_numrows (resource cursor)
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12256943
$rows = ora_numrows ($put_your_resource_cursor_here);
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12257069
@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
 
LVL 12

Expert Comment

by:minichicken
ID: 12257091
hmm... alright, thanks for the info :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question