CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Need to add functionality to SQL::Statement (I think)

 



S_Shrum
User

Feb 10, 2002, 2:28 AM

Post #1 of 4 (308 views)
Need to add functionality to SQL::Statement (I think) Can't Post

I have recently started using the USE clause as I am tired of writting new code for stuff that already exists.

The problem I have now is that I am using the DBI and DBD::ANYDATA. They use SQL::Statement to parse and deal with the $sth. For basic SQL calls this works great. However, I am trying to do a SQL LIMIT call; in essence it is like data slicing. Say I have a recordset of 50 records, I can do:


Code
LIMIT offset, num




Code
LIMIT 21, 10



This would then return 10 records starting at record 21.

Looking through the SQL::Statement file I see nothing in there to handle LIMIT calls. It seems like it would be an easy thing to do but I am a bit hesitent about doing this to such a widely published file. Am I going about this the right way or should I email the original author? Anybody know what needs to be done to implement this sort of functionality?
Sean Shrum
sean@shrum.net
http://www.shrum.net/programming - Free Perl Scripts
http://www.shrum.net/soaring - Sailplane Soaring and Combat


Jasmine
Administrator

Feb 10, 2002, 4:00 PM

Post #2 of 4 (300 views)
Re: [S_Shrum] Need to add functionality to SQL::Statement (I think) [In reply to] Can't Post

Hello Sean,

I just took a look at the docs for SQL::Statement, and saw that limit is supported (at least as of version 1.002). From the docs:


my $l = $stmt->limit();
if ($l) {
my $offset = $l->offset();
my $limit = $l->limit();
}




In a SELECT statement you can use a LIMIT clause to implement cursoring:

SELECT * FROM FOO LIMIT 5
SELECT * FROM FOO LIMIT 5, 5
SELECT * FROM FOO LIMIT 10, 5


These three statements would retrieve the rows 0..4, 5..9, 10..14 of the table FOO, respectively. If no LIMIT clause is used, then the method $stmt->limit returns undef. Otherwise it returns an instance of SQL::Statement::Limit. This object has the methods offset and limit to retrieve the index of the first row and the maximum number of rows, respectively.


Have I misunderstood the question?



Jasmine


S_Shrum
User

Feb 12, 2002, 4:41 PM

Post #3 of 4 (285 views)
Re: [Jasmine] Need to add functionality to SQL::Statement (I think) [In reply to] Can't Post

That might be the problem.

I am using a newer build of ActiveState's Perl 630. When I run the PPM and install the SQL::Statement module, it is giving me the .1016 version of the module. If I do a 'upgrade' call, it states that the module is up to date (which it isn't). ActiveStates Modules web lists SQL::Statement as v.1021 (current) which lists LIMIT as supported (go figure).

There was some discussion on perlmonks.com as to whether or not 63x builds were compatable with the 62x modules; hence the 63x PPM going to a different repository for the modules. This question was never really answered...just speculated upon.

Any comments on this?

Also, where can one find a list of module repositories to redirect PPM to?
Sean Shrum
sean@shrum.net
http://www.shrum.net/programming - Free Perl Scripts
http://www.shrum.net/soaring - Sailplane Soaring and Combat


Jasmine
Administrator

Feb 12, 2002, 7:05 PM

Post #4 of 4 (284 views)
Re: [S_Shrum] Need to add functionality to SQL::Statement (I think) [In reply to] Can't Post

I wouldn't know the answer either, and I won't speculate Smile

The most current ppm repository is at http://activestate.com/PPMPackages/5.6plus/. This repository has SQL::Statement 1.001.

If you're using ppm3, you can list your current repositories by typing rep at the ppm prompt and details about that repository by typing rep describe 1 (where 1 is the number of the repository in question).

The following sequence adds the correct repository to the list of repositories, activates it, and installs the SQL::Statement 1.001.


Code
 ppm> rep add 56plus http://www.activestate.com/PPMPackages/5.6plus/   
Repositories:
1. 56plus
2. ActiveState PPM2 Repository
* 3. ActiveState Package Repository
ppm> rep set 1
Repositories:
* 1. 56plus
2. ActiveState PPM2 Repository
3. ActiveState Package Repository
ppm> install SQL::Statement
====================
Install 'SQL-Statement' version 1.001 in ActivePerl 630.
====================
Downloaded 41119 bytes.
Extracting package. This may take a few seconds.
Extracting 10/10: blib/arch/auto/SQL/Statement/.exists
Installing G:\usr\site\lib\SQL\Eval.pm
Installing G:\usr\site\lib\SQL\Parser.pm
Installing G:\usr\site\lib\SQL\Statement.pm
Installing G:\usr\site\lib\SQL\Dialects\ANSI.pm
Installing G:\usr\site\lib\SQL\Dialects\AnyData.pm
Installing G:\usr\site\lib\SQL\Dialects\CSV.pm
Writing G:\usr\site\lib\auto\SQL\Statement\.packlist
ppm > exit



Hope this helps,

Jasmine


(This post was edited by Jasmine on Feb 12, 2002, 7:14 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives