Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Getting Perl Data Structures from DBI queries

by jZed (Prior)
on Apr 21, 2004 at 23:53 UTC ( [id://347212]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Getting Perl Data Structures from DBI queries
in thread Getting Perl Data Structures from DBI queries

Download the latest release of SQL::Statement (v.1.08 or higher). There were bugs in capitalization on preveious versions.

If what you are looking for is a way to store objects in a database, here is an example of one way to store an object (in this case a CGI.pm query object) in a database and then retrieve it

#!perl -w use strict; use DBI; use CGI; my $dbh = DBI->connect("DBI:DBM(RaiseError=1):mldbm=Storable"); my $sql = { drop => "DROP TABLE test" , create => "CREATE TABLE test (name VARCHAR(10), cgi_obj BLOB)" , insert => "INSERT INTO test (name,cgi_obj) VALUES (?,?)" , select => "SELECT cgi_obj FROM test WHERE name=?" }; populate( Barney => new CGI('species=dinosaur&color=purple') ); my $q = $dbh->selectrow_array( $sql->{select},{},'Barney'); my $rv = ( $q->param('color') eq 'purple' ) ? "ok" : "bad"; print "$rv!\n"; sub populate { eval { $dbh->do($sql->{drop}) }; $dbh->do( $sql->{create} ); $dbh->do( $sql->{insert},{},@_); } __END__

Replies are listed 'Best First'.
Re: Re: Re: Getting Perl Data Structures from DBI queries
by helphand (Pilgrim) on Apr 22, 2004 at 00:45 UTC
    Download the latest release of SQL::Statement (v.1.08 or higher). There were bugs in capitalization on preveious versions.

    Ahh, that explains it. Unfortunately, ActiveState's PPM only has v1.06, but at least we know why it failed.

    Thanks for the second example (had to update my DBI and install MLDBM to get it to run), that one is more along the lines of what I was expecting, it's appreciated.

    Scott
      Unfortunately, ActiveState's PPM only has v1.06, but at least we know why it failed.
      SQL::Statement is pure perl so you can use nmake.exe (free from microsoft!) to install it. Either use CPAN.pm, or just download, unzip and nmake it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://347212]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.