How can I perform LIMIT clause as I usually do in MySQL?
LIMIT clause let users to fetch only a portion rather than the whole records as the result of a query. This is particularly efficient and useful for paging feature on web pages, where users can navigate back and forth between pages. Using InterBase, this can be emulated by writing a stored procedure.
LIMIT clause let users to fetch only a portion rather than the whole records as the result of a query. This is particularly efficient and useful for paging feature on web pages, where users can navigate back and forth between pages. Using InterBase (Firebird is explained later), this can be emulated by writing a stored procedure. For example, to display a portion of table_forum, first create the following procedure: CREATE PROCEDURE PAGING_FORUM (start INTEGER, num INTEGER) RETURNS (id INTEGER, title VARCHAR(255), ctime DATE, author VARCHAR(255)) AS DECLARE VARIABLE counter INTEGER; BEGIN counter = 0; FOR SELECT id, title, ctime, author FROM table_forum ORDER BY ctime INTO :id, :title, :ctime, :author DO BEGIN IF (counter = :start + :num) THEN EXIT; ELSE IF (counter >= :start) THEN SUSPEND; counter = counter + 1; END END !! SET TERM ; !! And within your application: # fetch record 1 – 5: $res = $dbh->selectall_arrayref(“SELECT * FROM paging_forum(0,5)”); # fetch record 6 – 10: $res = $
Related Questions
- Period of Service top ยง 1002.99 Is there a limit on the total amount of service in the uniformed services that an employee may perform and still retain reemployment rights with the employer?
- If I exceed the ATM withdrawal limit while performing IBFT, will I be able to perform same transaction (InterBank GIRO) via AmOnline?
- How can I perform LIMIT clause as I usually do in MySQL?