Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Recalcitrant placeholders

by GrandFather (Saint)
on Jul 04, 2021 at 21:22 UTC ( #11134636=note: print w/replies, xml ) Need Help??


in reply to Recalcitrant placeholders

Of error handling and calling selectrow_array in scalar context the DBI documentation says:

If any method fails, and "RaiseError" is not set, selectrow_array will return an empty list.

If called in a scalar context for a statement handle that has more than one column, it is undefined whether the driver will return the value of the first column or the last. So don't do that. Also, in a scalar context, an undef is returned if there are no more rows or if an error occurred. That undef can't be distinguished from an undef returned because the first field value was NULL. For these reasons you should exercise some caution if you use selectrow_array in a scalar context, or just don't do that.

Does any of that ring alarm bells? Maybe setting RaiseError will help if you haven't already?

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Recalcitrant placeholders
by Bod (Curate) on Jul 04, 2021 at 22:18 UTC

    The query doesn't return more than one column.

    However, I checked it wasn't a scalar issue in one of the things I tried...
    - Forcing array context my ($crid) = $crm->db->selectrow_array - no change

    Raise Error is on by default and would be caught by the error trapping on the next line.

    edit - it also isn't returning undef, it is returning zero which is what is really confusing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11134636]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2021-10-22 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (86 votes). Check out past polls.

    Notices?