dbTalk Databases Forums  

[BUGS] BUG #1816: Insert null values on a null field

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #1816: Insert null values on a null field in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rafael Barrios
 
Posts: n/a

Default [BUGS] BUG #1816: Insert null values on a null field - 08-11-2005 , 08:15 AM






Thanks for your valuable response.
---------- Original Message -----------
From: Richard Huxton <dev (AT) archonet (DOT) com>
To: Rafael Barrios <rbarrios (AT) emdis (DOT) net.co>, pgsql-bugs (AT) postgresql (DOT) org
Sent: Thu, 11 Aug 2005 08:14:13 +0100
Subject: Re: [BUGS] BUG #1816: Insert null values on a null field

Quote:
Rafael Barrios wrote:
Richard, thanks for your response.
here is te information you request:

Don't forget to cc: the mailing list.

CREATE TABLE tbarrio (
bar_coddep character varying(2) NOT NULL,
bar_codmun character varying(3) NOT NULL,
bar_codbarrio character varying(3) NOT NULL,
bar_barrio character varying(40) NOT NULL,
bar_zongeografica character varying(1) NOT NULL
);

ALTER TABLE ONLY tbarrio
ADD CONSTRAINT pk_tbarrio PRIMARY KEY (bar_coddep, bar_codmun,
bar_codbarrio);

ALTER TABLE ONLY tbarrio
ADD CONSTRAINT fk_tbarrio_tmunicipio FOREIGN KEY (bar_coddep, bar_codmun)
REFERENCES tmunicipio(mun_coddep, mun_codmun) ON UPDATE CASCADE;

failling Insert: (adds records to table 'barrio' observe empty values..)

INSERT INTO tbarrio VALUES ('05', '001', '', '', '');

These aren't null - they are empty strings. You haven't forbidden
empty strings.

You'll want constraint(s) to do something like:

ALTER TABLE tbarrio
ADD CONSTRAINT no_empty_codbarrio
CHECK (bar_codbarrio > '');

http://www.postgresql.org/docs/8.0/s...ltertable.html

HTH
--
Richard Huxton
Archonet Ltd
------- End of Original Message -------


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.