in reply to Re^4: SQL Insert with blank in the middle
in thread SQL Insert with blank in the middle

Well, beauty is in the eye of the beer holder, but ... easier to read? How is

$dbh2->do("INSERT INTO PerlTest (Postcode,street_column,streetCount) V +ALUES (?,?,?)", undef, '', $mystreet, 0);
easier to read than
$dbh2->do("INSERT INTO PerlTest (Postcode,street_column,streetCount) V +ALUES ('',?,0)", undef, $mystreet);
? Not speaking about
my $sth = $dbh2->prepare("INSERT INTO PerlTest (Postcode,street_column +,streetCount) VALUES (?,?,?)"); ... $sth->execute('', $mystreet, 0);
versus
my $sth = $dbh2->prepare("INSERT INTO PerlTest (Postcode,street_column +,streetCount) VALUES ('',?,0)"); ... $sth->execute($mystreet);

Plus it makes the errors more likely, not less. IMnsHO.

Jenda
Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^6: SQL Insert with blank in the middle
by CountZero (Bishop) on Jul 08, 2010 at 20:28 UTC
    It is easier to read and makes errors less likely because all parameters are always together and you do not have to look at two places.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      The thing is ... are those two "parameters"?

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        Not if you look at it very strict, but I consider all input that can be parametrized to be a parameter, but YMMV.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James