Re: Why isn't LIMIT functionality included in CDBI?

[prev] [thread] [next] [Date index for 2004/05/21]

From: Andy Grundman
Subject: Re: Why isn't LIMIT functionality included in CDBI?
Date: 17:40 on 21 May 2004
Alexander Karelas wrote:

> Why isn't LIMIT functionality included in CDBI?
> 
> I know different database engines have different syntax for LIMIT, i.e. 
> MySQL uses LIMIT x,y whereas Postgres uses LIMIT x OFFSET y, but still 
> the developer could just write:
> 
> { limit => "x,y" }, if he uses MySQL, and
> { limit => "x offset y" }, if he uses Postgres.
> 
> Is there any reason this isn't desirable behaviour?
> 
> Perhaps it should be implemented somewhere in Class::DBI::mysql?
> 
> Alex

I believe this would have to be in the database-specific modules as 
every database does it differently.  For Oracle, the following syntax is 
necessary to mimic MySQL's LIMIT function:

SELECT $columns FROM ( SELECT a.*, rownum rnum FROM ( $sql ) a WHERE 
rownum <= $y ) WHERE rnum >= $x";

$sql is the entire SQL statement you want to limit.

I found this at 
http://asktom.oracle.com/pls/ask/f?p=4950:8:140438119304640675::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:127412348064,

-Andy

Why isn't LIMIT functionality included in CDBI?
Alexander Karelas 17:33 on 21 May 2004

Re: Why isn't LIMIT functionality included in CDBI?
Andy Grundman 17:40 on 21 May 2004

Re: Why isn't LIMIT functionality included in CDBI?
Edward J. Sabol 02:28 on 22 May 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52