Re: [SQL] Table constraints and INSERT

2006-05-17 Thread Tom Lane
Niklas Johansson <[EMAIL PROTECTED]> writes: > You must cast the integer column to a float or numeric, try: Since the CHECK is expecting an exact result, better use numeric. regards, tom lane ---(end of broadcast)--- TIP 5:

Re: [SQL] Table constraints and INSERT

2006-05-17 Thread Niklas Johansson
On 17 maj 2006, at 08.42, Risto Tamme wrote: INSERT INTO "PART" ("P_PARTKEY","P_RETAILPRICE") VALUES(999,90109.89); but it fails: ERROR: new row for relation "PART" violates check constraint "PART_check" The P_PARTKEY column is an integer, which means the expression P_PARTKEY/10 will yield

[SQL] Table constraints and INSERT

2006-05-16 Thread Risto Tamme
Hello I use PostgreSQL in my program and I found a strange behavior, at least for me. I have a simple table with constraint CREATE TABLE "PART" ( "P_PARTKEY" int4 NOT NULL, "P_RETAILPRICE" numeric, CONSTRAINT "PART_PRIMARY" PRIMARY KEY ("P_PARTKEY"), CONSTRAINT "PART_check" CHECK ("P_RET