Search Postgresql Archives

Re: problems with function pg_catalog.btrim(date)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karina Guardado <karina.guardado@xxxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux