Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: datatype from SQL

by VSarkiss (Monsignor)
on Jun 23, 2006 at 17:23 UTC ( #557267=note: print w/replies, xml ) Need Help??

in reply to datatype from SQL

The fetch method on a DBI statement handle object returns a reference to an array containing the value, not the value itself (it's an alias for fetchrow_arrayref). You need to do something like:

if ($in{'requestID'} == $newUID->[0])
to get the value in the row.

I just realized your code snippet says fetchrow, not fetch. To my knowledge, there's no fetchrow method in DBI. If you're not using DBI, ignore this note (what are you using?); if you are, what method are you actually calling?

Replies are listed 'Best First'.
Re^2: datatype from SQL
by jck (Scribe) on Jun 23, 2006 at 17:36 UTC
    well, i tried your suggestion, changing $newUID to $newUID->[0], but it gave me the following error:
    Can't use string ("1") as an ARRAY ref while "strict refs" in use at n line 61.
    so i think that $newUID must be the scalar ref, not an array ref, right?

      What version of DBI are you using and which DBD driver? You're use of $in{param} leads me to believe you're also using cgi-lib (instead of CGI) and may have a very old installation.


      Update: And is this an XY Problem ... are you just trying to get create the next UID ... if so, most DB's have an auto-incrementing field feature.

Re^2: datatype from SQL
by jck (Scribe) on Jun 23, 2006 at 17:29 UTC
    i thought that might be the problem, but then, why does
    print $newUID
    give me the value "2"?? (or "1", or whatever)??
Re^2: datatype from SQL
by jck (Scribe) on Jun 23, 2006 at 17:32 UTC
    i think i may have had the whole fetchrow_arrayref, now it's fetch...i may have cut & pasted an intermediate incorrect version.

    and, yes, i am using DBI

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2016-10-27 00:01 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (350 votes). Check out past polls.