perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rodney Broom" <rbr...@home.com>
Subject Re: error DBI with quote
Date Mon, 10 Jul 2000 18:04:09 GMT
Ack! I can't find the string "not valid sentence" in DBI.pm, Apache/DBI.pm, or
in Oracle.pm, so I'll ignore it.

Here's your code:

      $phrase = "Mike's car"
      $sql=qq{INSERT INTO TABLE_NAME (PHRASE) VALUES (?)};
      my $insert_phrase=$dbh->prepare($sql);
      $sql->bind_param(1,$dbh->quote($phrase),SQL_VARCHAR);
      $insert_phrase->execute();

There are several little problems it this chunk that lead me to believe that
this was not copy-n-pasted from the actual code. But who cares, try this:

      $phrase = "Mike's car"
      $sql=qq{INSERT INTO TABLE_NAME (PHRASE) VALUES (?)};
      #-- The return from prepare() is a statement handle
      my $insert_sth = $dbh->prepare($sql);
      $insert_sth->execute($phrase);

That's it, just pass a list of values into execute(). As for Michael's comment
of not being sure whether you can use prepare() for non-SELECT-statements, the
answer is yes. In fact, all statements have to be prepare()ed when using DBI,
it's just a matter of who does the prepare(), you or DBI.

----
Rodney Broom




Mime
View raw message