David,

Your solution is similar to mine.  But I like your use of the hash slice 
better.  I keep forgetting about those darn slices.

-----Original Message-----
From: David [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 21, 2005 6:53 AM
To: [email protected]
Subject: Re: inserting data coming from a hash

A placeholder only holds one place.  You would need to have a
placeholder for each value you wanted to insert.  Something like

  my $sth = $dbh->prepare('insert into holiday ('
                          . join(',', sort keys %hash)
                          . ') values (?, ?, ?, ?)')
      || die "prepare failed";
  $sth->execute(@hash{sort keys %hash})
      || die "execute failed";

if your hash keys correspond to your column names.

dd
-- 
David Dooling

Reply via email to