Re: varchar error - Mailing list pgsql-php

From Volkan YAZICI
Subject Re: varchar error
Date
Msg-id 7104a73705062301332ca4bb4d@mail.gmail.com
Whole thread Raw
In response to varchar error  ("Raul Secan" <raul@zerosoft.ro>)
List pgsql-php
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.

pgsql-php by date:

Previous
From: "Raul Secan"
Date:
Subject: varchar error
Next
From: Anthony van den Berg
Date:
Subject: Re: varchar error