i5_query and Pagination component - help

General discussion on Zend Core for IBM System i
Post Reply
milkplus
Posts: 2
Joined: Tue Jun 09, 2009 10:40 am

i5_query and Pagination component - help

Post by milkplus » Tue Jun 23, 2009 4:14 pm

Hi guys,

I have some problem with pagination!

I use i5_query function to get data and I need to build a pagination whit rows limit:

suppose I have 1000 records and I would like to show only 20 rows in each page.

I see there is also the Zend_Paginator component http://framework.zend.com/manual/en/zend.paginator.html can you show me an example?


User avatar
shlomov
Zend Global Support
Posts: 139
Joined: Mon Dec 29, 2008 2:38 pm

Re: i5_query and Pagination component - help

Post by shlomov » Thu Jul 02, 2009 4:23 pm

1. ZF is a good way to go:
http://framework.zend.com/manual/en/zend.paginator.html

2. Cursor declaration.
Add the scroll keyword in order to make the cursor scrollable, the cursor permits random access.
FETCH AFTER positions to the end of the record set. This is similar to using the SETGT in native RPG I/O in order to position to the end of the file.
FETCH BEFORE positions to the beginning of the file.
FETCH PRIOR operation. this fetch retrieves the previous row in the return set. (Like RPG's READP opcode)
Fetch First and Last
You can retrieve the first and last rows of an SQL query, using a scrollable cursor.
Use FETCH FIRST and FETCH LAST.

FETCH FIRST to retrieve the first row from the result set.
FETCH CURRENT re-reads the same row from the cursor.

Fetch Relative
Normal practice is to read a cursor sequentially, but FETCH RELATIVE allows a deviation from the practice.
The form is FETCH RELATIVE n, where n is the number of rows before (if n is negative) or after (if n is positive) the last fetched row. The following code reads the odd-numbered rows from the result set, by reading the first row, then every second row following.


DECLARE CURSOR syntax:
http://publib.boulder.ibm.com/infocente ... h2clcu.htm

SELECT syntax:
http://publib.boulder.ibm.com/infocente ... stfets.htm

FETCH syntax:
http://publib.boulder.ibm.com/infocente ... stfets.htm
Shlomo Vanunu
IBM System i

sirshurf
Posts: 14
Joined: Thu Feb 26, 2009 11:25 am

Re: i5_query and Pagination component - help

Post by sirshurf » Mon Mar 01, 2010 8:14 am

Do we have a Fetch Relative in i5_fetch ?

If so, how do we jump to line?

I am on V5.4 and have a problem with subselects on Joins :(

sirshurf
Posts: 14
Joined: Thu Feb 26, 2009 11:25 am

Re: i5_query and Pagination component - help

Post by sirshurf » Mon Mar 01, 2010 8:35 am

Ok, sorry for previouse post.

using i5_data_seek works on SQL statement

Post Reply