pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Volkan YAZICI <volkan.yazici@gmail.com>
To: Raul Secan <raul@zerosoft.ro>
Cc: pgsql-php@postgresql.org
Subject: Re: varchar error
Date: Thu, 23 Jun 2005 11:33:47 +0300
Message-ID: <7104a73705062301332ca4bb4d@mail.gmail.com> (raw)
In-Reply-To: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro>
References: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro>

Hi,

On 6/23/05, Raul Secan <raul@zerosoft.ro> wrote:
> 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 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 done
> in PostreSQL? Maybe in CREATE TABLE definition? 

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.



view thread (6+ messages)  latest in thread

Message-ID: <7104a73705062301332ca4bb4d@mail.gmail.com>
Permalink:  ../7104a73705062301332ca4bb4d@mail.gmail.com/
Also on:    postgresql.org/message-id/7104a73705062301332ca4bb4d@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: volkan.yazici@gmail.com, raul@zerosoft.ro
  Subject: Re: varchar error
  In-Reply-To: <7104a73705062301332ca4bb4d@mail.gmail.com>
  References: <000d01c577cc$2c9c1f30$0a10a8c0@zerosoft.ro> <7104a73705062301332ca4bb4d@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox