Argh! PMT_ID != PMTDBT_ID!!

jjore on 2006-10-03T21:21:05

This is the second time this week that I've used a SQL join like

PMT.PMT_ID = PMTDBT.PMTDBT_ID
but meant to say
PMT.PMT_ID = PMTDBT.PMT_ID
. Both values are of type NUMERIC but I wish Sybase knew that their domains are unrelated and that each were of a distinct type PMT_ID and PMTDBT_ID or similar.

That way it'd just be invalid to compare the two unless I somehow defined a way to convert from one of those types to the other.


Data Types in SQL

Ovid on 2006-10-03T21:36:06

As I understand it from C.J. Date's description of the relational model, each column must have a name and a type. Operators must be defined for each type and if types don't have an operator defined which allows them to be compared, the SQL doesn't even compile. If that were true, the following mistake would never happen without an explicit typecast:

SELECT name FROM customer WHERE age > id

Admittedly that's a trivial (one might say ridiculous) example, but it illustrates the ridiculousness of the underlying problem. Since you'd be able to define your IDs as different types, your problem would go away. Unfortunately, I know of no databases which support this. (I'm not saying they don't exist, though).

Re:Data Types in SQL

jjore on 2006-10-03T21:44:20

Exactly. I thought briefly about linking to something you'd written before about this but mostly I wanted to complain that I'd been bitten by this typo twice within a week.

It sucks.