Re: problems with function pg_catalog.btrim(date)

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: problems with function pg_catalog.btrim(date)
Дата
Msg-id
4234.1251940259@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
problems with function pg_catalog.btrim(date) Karina Guardado <karina.guardado@ues.edu.sv>
Re: problems with function pg_catalog.btrim(date) Tom Lane <tgl@sss.pgh.pa.us>
Karina Guardado  writes:
> I hope some one can help me, I have created  the following function but 
> I always get the error that there is not function 
> pg_catalog.btrim(date), in the version postgresql 8.1 it worked but now 
> it does not so I don't know if it is related with a configuration 
> problem of the postgresql or somethin in the function code  :

What in the world do you imagine that trim() on a date would be good
for?  Just get rid of the "date(trim())" lines.

I think this accidentally failed to fail pre-8.3 because there was an
implicit cast from date to text, so it would convert the date to text,
remove leading/trailing blanks (which there wouldn't be any of), and
then convert the string back to date.  An expensive and pointless no-op.

This bit is going to fail too:

> dia :=CAST(substring(hoy from 1 for 2)  AS integer );
> nmes := CAST (substring(hoy from 4 for 2) AS integer);
> anho := CAST(substring(hoy from 7 for 4) AS integer );

While that sort of worked in 8.1, it was always bad coding style and
fragile as can be --- think what will happen if the user changes the
datestyle setting.  Replace this with extract(day ... ) and so forth,
and you'll have code that is safer, faster, and more standard/portable.

			regards, tom lane
В списке pgsql-general по дате отправления
От: Joshua D. Drake
Дата:
От: David Fetter
Дата:
FAQ