Em 23/10/08, Tiago N. Sampaio<[EMAIL PROTECTED]> escreveu:
>
> Então, a definição da funcao que vem com o pg agora é
> to_number (text,text)..
> Ai dá pau...

A definição da to_number *sempre* foi (text, text).


> Por isso que to tentando criar o wrapper..
> um que eu achei até funciona, mas dá core dump no postgres hehe...
> E foi um erro da ultima tentativa aquele parentesis a mais...
> Nem tinha visto ele.
>

Creio que seu problema seja decorrente de:
http://www.postgresql.org/docs/current/interactive/release-8-3.html
"E.5.2.1. General

    *      Non-character data types are no longer automatically cast
to TEXT (Peter, Tom)

      Previously, if a non-character value was supplied to an operator
or function that requires text input, it was automatically cast to
text, for most (though not all) built-in data types. This no longer
happens: an explicit cast to text is now required for all
non-character-string types. For example, these expressions formerly
worked:

      substr(current_date, 1, 4)
      23 LIKE '2%'

      but will now draw "function does not exist" and "operator does
not exist" errors respectively. Use an explicit cast instead:

      substr(current_date::text, 1, 4)
      23::text LIKE '2%'

      (Of course, you can use the more verbose CAST() syntax too.) The
reason for the change is that these automatic casts too often caused
surprising behavior. An example is that in previous releases, this
expression was accepted but did not do what was expected:

      current_date < 2017-11-17

      This is actually comparing a date to an integer, which should be
(and now is) rejected — but in the presence of automatic casts both
sides were cast to text and a textual comparison was done, because the
text < text operator was able to match the expression when no other <
operator could.

      Types char(n) and varchar(n) still cast to text automatically.
Also, automatic casting to text still works for inputs to the
concatenation (||) operator, so long as least one input is a
character-string type."

e, caso você faça uso intensivo deste tipo de conversão, então terá um
grande pepino para descascar...

Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a