X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 48E16D1B432; Thu, 11 Dec 2003 14:43:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48340-01; Thu, 11 Dec 2003 10:43:01 -0400 (AST) Received: from rectorat2.usj.edu.lb (rectorat2.usj.edu.lb [193.227.187.132]) by svr1.postgresql.org (Postfix) with SMTP id 31981D1B433; Thu, 11 Dec 2003 10:42:32 -0400 (AST) Received: from nagib ([192.168.100.246]) by rectorat2.usj.edu.lb (8.11.6/8.11.6) with SMTP id hBBEaCO28803; Thu, 11 Dec 2003 16:36:24 +0200 Message-ID: <001401c3bff4$49abd7f0$f664a8c0@nagib> Reply-To: "Nagib Abi Fadel" From: "Nagib Abi Fadel" To: "generalpost" , "developPost" Subject: Should we consider empty fields as NULL values when dealing with string columns ? Date: Thu, 11 Dec 2003 16:36:56 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0011_01C3C004.FD9D6A20" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=HTML_40_50 X-Spam-Level: X-Archive-Number: 200312/626 X-Sequence-Number: 54020 This is a multi-part message in MIME format. ------=_NextPart_000_0011_01C3C004.FD9D6A20 Content-Type: text/plain; charset="windows-1256" Content-Transfer-Encoding: quoted-printable HI, let's say we have the following table : # CREATE TABLE tempo (col1 varchar(3) not null); CREATE TABLE # insert INTO tempo VALUES (''); INSERT 11420541 1 the insert command works.=20 The issue is that since the column col1 is defined as character with not nu= ll attribute, shouldn't we deny such inserts (i mean inserting empty fields)??? (PS: i am using postresql 7.3.2) When using script languages (like PHP) if by mistake the variable is not de= fined such insert is possible (let's say we have a variable $col1_value and= after a long day of work we make a mistake and write it $col_value). This "problem" is solved by adding the constraint: ALTER TABLE tempo add constraint col1_check check(col1!=3D''); ------=_NextPart_000_0011_01C3C004.FD9D6A20 Content-Type: text/html; charset="windows-1256" Content-Transfer-Encoding: quoted-printable
HI,
let's say we have the following=20 table :
 
# CREATE TABLE tempo (col1 varchar(3)= not=20 null);
CREATE TABLE
# insert INTO tempo VALUES ('');
INSERT= 11420541=20 1
 
the insert command works.
 
The issue is that since the column co= l1 is=20 defined as character with not null attribute,
shouldn't we deny such inserts (i mean ins= erting=20 empty fields)???
(PS: i am using postresql 7.3.2)
 
When using script languages (like PHP) if = by=20 mistake the variable is not defined such insert is possible (let'= s=20 say we have a variable $col1_value and after a long day of work w= e=20 make a mistake and write it $col_value).
 
This "problem" is solved by adding the=20 constraint:
 ALTER TABLE tempo add constrain= t=20 col1_check check(col1!=3D'');
 
------=_NextPart_000_0011_01C3C004.FD9D6A20--