in reply to Re^2: Perl/SQL syntax error
in thread Perl/SQL syntax error

Your example using placeholders (or bind variables - they are the question marks):
my $sth = $dbh->prepare(<<sqlend insert into url_connect (sourceIP, dt, tm, remoteIP) values (?, ?, ?, ?) sqlend # and then: $sth->execute($sourceIP, $date, $time, $targetIP); # and again: $sth->execute($sourceIP2, $date2, $time2, $targetIP2);
The idea is to prepare the query once and possibly execute it many times over, just supplying new values for the bind-variables.

The overhead of preparing the query on the database-server(parsing the sql, checking persmission, generating data-access paths etc) then just occurs once (and this is essential for scalability on systems like Oracle or DB2).

Replies are listed 'Best First'.
Re^4: Perl/SQL syntax error
by patt (Scribe) on Jul 04, 2009 at 13:54 UTC
    Thanks Morgon. I have done that, but now have a new error msg - I'll sort that one out myself. Data is now being inserted into my table, but there seems to be a formatting problem in the date column. Back to the drawing board. Thanks for all the invaluable advice. I have learned something new today, and I am very happy with that.
      The standard, default date format for mysql is just "2009-07-04 10:45:23". Make your date string look like that, and you'll do fine.
        Yes I noticed that slight problem. I was using the European time syntax, then realised that SQL used a different format... Thanks for your help
Re^4: Perl/SQL syntax error
by patt (Scribe) on Jul 04, 2009 at 14:07 UTC
    Thanks Morgon. I have done that, but now have a new error message - I'll sort that out myself. Data is being inserted into the table, but there is a formatting problem in the date column. Back to the drawing board. Thanks for the invaluable advice. I have learned something new today, and am very happy with that...

    Content restored by GrandFather

      Hi,
      Why don't you use quote() function ?
      my $quotedString = $dbh->quote( $string );

      - Raja