If I understand your question, it seems like you would want to do:
$sth = $dbh->prepare(q{
insert into tab (date,type,federal,active) values (?,?,?,?); });
Then in a loop:
$dref = $hash{$d}; # $d has "Veterans day" in one iteration
$sth->execute($dref->date,$dref->type,$dref->federal,$dref->active);
OR, if you want to improve management of your members, consider the following.
This assumes member names = your column names, and ensures the bind order is in
sync with the SQL column order.
my @members = qw{date type federal active}; #define members $sth =
$dbh->prepare(
q"insert into tab (" . $join(",", $members)
. q") values (" . $join(",", "?" x @members)
. q");"
);
Then in a loop:
$dref = $hash{$d}; # $d has "Veterans day" in one iteration my $i = 1;
$sth->bind_param($i++, $d->{$_}) foreach @members; $sth->execute();
Warning. This is untested code. But hopefully you get the idea.
Was this the kind of answer that you were looking for?
-----Original Message-----
From: Robert [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 21, 2005 6:37 AM
To: [email protected]
Subject: inserting data coming from a hash
This is my hash structure:
"Veterans Day" => {
date => '20051111',
type => 'US',
federal => 'true',
active => 'true',
},
Would I just use a placeholder (?) in my statement and pass it in via that?
It will be in a loop as I have quite a few.
Thoughts and suggestions would be appreciated.
Robert