I would first advise reading a book on SQL. Since I have never seen an
"insert into table set ..." syntax in standard SQL, so I can imagine this is
wrong too.
Then you should read the docs on placeholders, since they can only hold
values to be bounded and not 90 percent of the query.
After doing so if you have any more question, we'll be glad to help.
Ilya
> -----Original Message-----
> From: Sajiv Shrivastva [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 11, 2001 7:42 PM
> To: [EMAIL PROTECTED]
> Subject: Inserting a concatenated string as a SET
>
>
> Hi,
>
> I'm trying to insert a long concatenated string from a hash of
> hashes into
> an sql db. I have not had much luck?
> Whats the best manner to do this?
>
> sub mysend {
> #send the data to the db
> my($DMConcat);
> my($ToConcat);
>
> $dbh = DBI->connect("DBI:mysql:en_us:xena", "", "");
> $q1 = $dbh->prepare("INSERT INTO corpus_appstats SET ?");
> $q2 = $dbh->prepare("INSERT INTO ctxt_appstats SET ?");
> $Toconcat .="corpus_id =".$corp;
> $Toconcat .=", datetime_start=$dates";
> $Toconcat .=", datetime_end=$dateend";
> foreach $Module (keys %stats){
> foreach $DM (keys %{ $stats {$Module}}){
> foreach $type (keys %{$stats {$Module}{$DM}} ){
> foreach $rc (keys %{$stats {$Module}{$DM}{$type}}){
> if ($Module eq "Module") {
> if (length $rc > 0){
> $q3 = $dbh->prepare ("select dm_id from
> dm where dm_name =? and
> dm_type =? and rc_name = ?");
> $q3->execute($DM, $type, $rc);
> $dm_id = $q3->fetchrow_array();
> print $dm_id, "after search \n";
> $DMconcat .="corpus_id=$corp";
> $DMconcat .=", dm_id=$dm_id";
> $DMconcat .=", datetime_start=$dates";
> $DMconcat .=", datetime_end=$dateend";}
>
> }
> foreach $feild (keys
> %{$stats{$Module}{$DM}{$type}{$rc}}){
> if ($Module eq "Total") {
> $Toconcat .=", $feild
> =$stats{$Module}{$DM}{$type}{$rc}{$feild}"; }
> if ($Module eq "Module") {
> if (length $rc > 0){
> $DMconcat .=",
> $feild=$stats{$Module}{$DM}{$type}{$rc}{$feild}";}
> else{
> $Modconcat.=",
> $feild=$stats{$Module}{$DM}{$type}{$rc}{$feild}";
> }
> }
> }
>
>
> }
> chomp ($DMconcat);
> $DMconcat .= $Modconcat;
> print $DMconcat, "\n";
> $q2->execute($DMconcat);
> undef $DMconcat;
>
>
> }
> undef $Modconcat;
> }
> }
> chomp ($Toconcat);
> print $Toconcat, "\n";
> $q1->execute($Toconcat);
> $q1->finish ();
> $q2->finish ();
> $q3->finish ();
> $dbh->disconnect();
> undef $Toconcat;
>
> }