Re: Understanding FETCH

Daniel Dittmar <[email protected]>
Newsgroups gmane.comp.db.sapdb.general
Organization SAP AG
Message-ID <[email protected]>
Simon Spielmann wrote:
> I want to get only some rows of a longer table to show them on a web page.
> I read that there isn't a limt x,y statment as in MySQL. The solution 
> seems to be using the FETCH statement,
> but I can't understand how.
> Maybe someone can give me an example how to do it (it has to work with 
> ODBC, because my web application uses PHP).

FETCH is issued internally when you go to the next row of a cursor 
(odbc_fetch_row). The ODBC driver will generally FETCH as much rows as 
there is place in the communication buffer and return these one by one 
without additional calls to the database. Only when all the rows in 
buffer have been returned to the application is the next FETCH executed.

Don't execute FETCH yourself because this will most certainly confuse 
the ODBC driver.

If you simply want to assure that not all data of the cursor is copied 
into application memory, then you have to do nothing, because the  ODBC 
driver won't do this anyway.

If you want to limit the number of rows in the cursor so you don't have 
to keep track of the count yourself, there might be an ODBC option for 
that which you could set using odbc_setoption.

Daniel Dittmar

-- 
Daniel Dittmar
SAP DB, SAP Labs Berlin
[email protected]
http://www.sapdb.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.