in reply to DBI::ODBC Delete Error

I'm guessing here, so bear with me...

I remember reading in the camel book how one ought to be careful about using || vs. 'or' when used in conjuction with list operators (or subs without parenthesis).

i.e. use
 open FILE, ">$file" or die "Oops";
or
 open (FILE, ">$file") || or die "Oops";
but not
 open FILE, ">$file" || or die "Oops";

So, I'm a guessing that you need to change line 30 to (note additional parenthesis) ...

$sth->execute() || die "Could not execute SQL statement ... maybe inva +lid?\n$!";
or maybe change the || to 'or'
$sth->execute or die "Could not execute SQL statement ... maybe invali +d?\n$!";
Let me know if I guessed right (or even if I guessed wrong).

Sandy

Quote from the camel book:

As lower precedence alternatives to &&, ||, and !, Perl proveds the and, or, and not operators. The behaviour of these operators is identical -- in particular, and and or short-ciruit like their counterparts, which makes them useful not only for logical expressions but also for control flow.

Since the precedence of these operators is much lower than the ones borrowed from C, you can safely use them after a list operator without the need for parentheses:

unlink "alpha", "beta", "gamma" or gripe (), next LINE;
With the C-style operators you'd have to write it like this:
unlink("alpha", "beta", "gamma") || (gripe(), next LINE);

Replies are listed 'Best First'.
Re: Re: DBI::ODBC Delete Error
by vbrtrmn (Pilgrim) on Jan 07, 2004 at 23:27 UTC

    I've used $sth->execute with and without the parenthesis, in the past, either way seems to work fine. Sans the code above, though CountZero's suggestion of quoting what I want to match in the SQL query worked.

    In your second open FILE example you duplicate the use of or. Read aloud it sounds like a stutter or you're mad.
    Open the file .. OR .. OR DIE!!!

    --
    paul

      In your second open FILE example you duplicate the use of or. Read aloud it sounds like a stutter or you're mad.

      Ooops...