Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: datatype from SQL

by VSarkiss (Monsignor)
on Jun 23, 2006 at 17:23 UTC ( [id://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.

Update
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 +ewsedit.pl 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.

      -derby

      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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-26 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found