problem storing a hash in DB using Storage::nfreeze Perl

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-04-16T13:57:23Z Indexed on 2010/04/16 14:13 UTC
Read the original article Hit count: 308

Filed under:
|
|
|

Hello,

I want to insert a hash in the db using Storage::nfreeze but the data is not inserted properly.

the code is as follow:

%rec=();
$rec{'name'} = 'my name';
$rec{'address'} = 'my address';

my $order1 = new Order();
$order1->set_session(\%rec);
$self->createOrder($order1);

sub createOrder {
my $self  = $_[0];
my $order = $_[1];


# Retrieve the fields to insert into the database.
my $st = $dbh->prepare("insert into order (session,.......) values(?,........)");

my $session   = %{$order->get_session()};
$st->execute(&Storable::nfreeze(\%session),.....);
$st->finish();

}

sub getOrder
{
     ...

    my $session = &Storable::thaw( $ref->{'session'} );
    .....
}    

the thaw is working fine because I tested it withe some rows that have been inserted correctly. but when I try to get a row that was inserted using the createOrder subroutine, I get an error saying" Storable binary image v36.65 more recent than I am (v2.7) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 415

the error comes from the line that have thaw. the nfreeze did not store the hash properly.

Can someone point me to what i m doing wrong in the createOrder subroutine?

Thanks in advance.

I know the module version have nothing to do with the problem.

© Stack Overflow or respective owner

Related posts about hash

Related posts about perl