Skip site navigation (1) Skip section navigation (2)

Re: varchar error

From: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>
To: Raul Secan <raul(at)zerosoft(dot)ro>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: varchar error
Date: 2005-06-23 08:33:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php

On 6/23/05, Raul Secan <raul(at)zerosoft(dot)ro> wrote:
>     mytext varchar(5)
> 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.



In response to

pgsql-php by date

Next:From: Anthony van den BergDate: 2005-06-23 08:40:51
Subject: Re: varchar error
Previous:From: Raul SecanDate: 2005-06-23 08:18:45
Subject: varchar error

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group