CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI: WHERE has changed to Numeric Comparison - SOLVED (or, at least a good work-around): Edit Log



jhumkey
Novice

Jan 21, 2015, 7:02 AM


Views: 35993
WHERE has changed to Numeric Comparison - SOLVED (or, at least a good work-around)

Old DBD:DBI:CSV program on a Linux host has been working for (15+?) years. Now need to port it to a newer AIX box.

The old (working) WHERE clause, . . . if it saw "5151" for a key, ONLY matched/updated "5151" in the master. But the latest CSV modules on the AIX host . . . "5151" matches "5151", but it ALSO (wrongly) matches "0005151".

Its as if the functionality of the WHERE comparison has changed from String/Textual to Numerical comparison.

I can't find (and I've looked hard) a way to "declare" (as string to force string comparison) or "quote" to force string comparison.

Has anyone found a way around this issue?

For an original/Master table like :

MasterTable
0005151,20150121085200,1000,0
5151,20150121085200,2000,0

An update entry like :

Update Entry
5151,20150121085200,22154,0

Should update ONLY the 5151 line in the master. (And on the old Linux app it does.) Like :

MasterTable
0005151,20150121085200,1000,0
5151,20150121085200,22154,0

But on the new AIX (newer DBD/DBI/CSV modules) . . . it updates both lines, like :

MasterTable
0005151,20150121085200,22154,0
5151,20150121085200,22154,0

Which is wrong (or at least very undesirable). Its as if the comparison has flipped over the years from literal string, to numerical and it sees 0005151 as equal to 5151.

$XMASTER_db->do("UPDATE XMASTER \
SET DateTime='$DateTime', LifeHours='$LifeHours' \
WHERE ( SerialNumber='$SerialNumber' AND \
LifeHours<'$LifeHours' AND \
DateTime<'$DateTime' ) ");

On the old-original code, it was escaped double quotes (like \" ) around the \"$SerialNumber\"

Had to switch to single quotes '$SerialNumber' on the new host/modules or I get stupid errors (like "Can't find column 5151").

Is there any way to FORCE String/Textual and non Numerical comparisons in a WHERE?

Thanks,

jkh


(This post was edited by jhumkey on Jan 23, 2015, 7:21 AM)


Edit Log:
Post edited by jhumkey (Novice) on Jan 23, 2015, 7:21 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives