X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 171B15295C for ; Thu, 23 Jun 2005 12:59:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72281-09 for ; Thu, 23 Jun 2005 15:59:10 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 10AAF5293C for ; Thu, 23 Jun 2005 12:59:09 -0300 (ADT) Received: (qmail 15677 invoked by uid 500); 23 Jun 2005 15:58:57 -0000 Date: Thu, 23 Jun 2005 10:58:57 -0500 From: Bruno Wolff III To: Raul Secan Cc: pgsql-php@postgresql.org Subject: Re: varchar error Message-ID: <20050623155857.GB14442@wolff.to> Mail-Followup-To: Bruno Wolff III , Raul Secan , pgsql-php@postgresql.org References: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/24 X-Sequence-Number: 3183 On Thu, Jun 23, 2005 at 11:18:45 +0300, Raul Secan wrote: > Hello, I just have this: > > CREATE TABLE test ( > mytext varchar(5) > ) WITHOUT OIDS; > > If I put a string with more than 5 chars in mytext, I receive an error, regarding the wrong lenght of the string. > > In MySQL I know that the string is automatically reduced to the number of char allowed by the column, even if I insert a longer string. > > I don't want to do this from PHP, and I was wandering how this can be done in PostreSQL? Maybe in CREATE TABLE definition? The way to do this is to use the substring function to do this. You can extract the first 5 characters of the string you are supplied.