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

Why?

:-)

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

  • Comment on Re^4: SQL Insert with blank in the middle

Replies are listed 'Best First'.
Re^5: SQL Insert with blank in the middle
by Jenda (Abbot) on Jul 08, 2010 at 13:26 UTC

    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.

      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.