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 3403052923 for ; Thu, 23 Jun 2005 05:33:55 -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 83625-02 for ; Thu, 23 Jun 2005 08:33:46 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by svr1.postgresql.org (Postfix) with ESMTP id 2F710528D9 for ; Thu, 23 Jun 2005 05:33:45 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 69so278750wra for ; Thu, 23 Jun 2005 01:33:47 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NRpLox8bklgiN2unfXGG6+FN6khrlo1gy5N7InqwwCPDTSGS4DZyKYPqu3cCBgBLxQs9WEMRz/iZdImgv9EDXBdNSlKfRieTxf0WuDdp+JA8g9BIJd/cz7HTGnWkvS0AO56/Brbm/yQI/Y/A7AlP4qLOs1MOj4MOEG7Wdlzi+ok= Received: by 10.54.145.8 with SMTP id s8mr1007216wrd; Thu, 23 Jun 2005 01:33:47 -0700 (PDT) Received: by 10.54.30.45 with HTTP; Thu, 23 Jun 2005 01:33:47 -0700 (PDT) Message-ID: <7104a73705062301332ca4bb4d@mail.gmail.com> Date: Thu, 23 Jun 2005 11:33:47 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: Raul Secan Subject: Re: varchar error Cc: pgsql-php@postgresql.org In-Reply-To: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.127 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/20 X-Sequence-Number: 3179 Hi, On 6/23/05, Raul Secan wrote: > CREATE TABLE test ( > mytext varchar(5) > ) WITHOUT OIDS;=20 > =20 > If I put a string with more than 5 chars in mytext, I receive an error, > regarding the wrong lenght of the string.=20 > =20 > 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 think that it's the function of database to manipulate the input. > I don't want to do this from PHP, and I was wandering how this can be don= e > in PostreSQL? Maybe in CREATE TABLE definition?=20 IMHO, you can create an insert (and update) procedure (like my_insert() and my_update()) with using substr() [1] function. [1] www.postgresql.org/docs/8.0/interactive/functions-string.html Regards.