in reply to Re: Unable to run SQL query
in thread Unable to run SQL query

Hi, I understand that using heredoc will solve the problem of detecting the quotes but how do I run the SQL query?

Replies are listed 'Best First'.
Re^3: Unable to run SQL query
by Mr. Muskrat (Canon) on Sep 07, 2009 at 13:49 UTC

    Try putting the prepare back in with $heredoc as its parameter.

Re^3: Unable to run SQL query
by graff (Chancellor) on Sep 07, 2009 at 18:00 UTC
    What Mr. Muskrat means is something like this:
    use strict; use DBI; my $dbh = DBI::connect( ... ) or die "DBI::connect failed"; my $sql = <<ENDSQL; SELECT ... FROM ... WHERE ... ... ENDSQL my $sth = $dbh->prepare( $sql ) or die "DBI::prepare() failed"; $sth->execute( ); ...
    (and remember to add parameter variables or values in the execute() call, if your sql statement has any "?" placeholders).