Обсуждение: CAST truncates without warning

Поиск
Список
Период
Сортировка

CAST truncates without warning

От
Mike G
Дата:
Hello,

If a column, data type text, with 22 characters of data, is then CAST(column_name as varchar(20)) shouldn't a warning
orerror be generated? 

If the source is a variable defined as text instead of directly from a table, using plpsql, would that matter?

Mike




Re: CAST truncates without warning

От
Tom Lane
Дата:
Mike G <mike@thegodshalls.com> writes:
> If a column, data type text, with 22 characters of data, is then CAST(column_name as varchar(20)) shouldn't a warning
orerror be generated? 

No.  This is per SQL spec.

You will get a warning if you assign the value to a varchar(20) table
column *without* any explicit cast.  This is also per SQL spec.

            regards, tom lane