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 04: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.