Re: varchar error

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: varchar error
Дата
Msg-id 20050623155857.GB14442@wolff.to
обсуждение исходный текст
Ответ на varchar error  ("Raul Secan" <raul@zerosoft.ro>)
Список pgsql-php
On Thu, Jun 23, 2005 at 11:18:45 +0300,
  Raul Secan <raul@zerosoft.ro> 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
inserta 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.

В списке pgsql-php по дате отправления:

Предыдущее
От: Marco Colombo
Дата:
Сообщение: Re: varchar error
Следующее
От: "Nick Stone"
Дата:
Сообщение: Pqsocket not implemented in PHP