Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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.

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?


Comment on Re: datatype from SQL
Select or Download Code
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

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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2015-07-01 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (11 votes), past polls