Proposal: is_castable
От | Michał Wadas |
---|---|
Тема | Proposal: is_castable |
Дата | |
Msg-id | CAMEnU0Ae+h5zFoEra004NXTaPxPYABv4B9SdR9Tm15mNPT6OOQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Proposal: is_castable
Re: Proposal: is_castable |
Список | pgsql-hackers |
Currently there is no way to check if CAST will succeed.
Therefore I propose adding new function: is_castable
SELECT is_castable('foo' as time) // false
SELECT is_castable('123' as numeric) // true
SELECT is_castable(1.5 as int) // true
SELECT is_castable('1.5' as int) // false
Many users write their own functions:
https://stackoverflow.com/q/10306830/2446102 (11k views, ~25 upvotes)
https://stackoverflow.com/a/16206123/2446102 (72k views, 70 upvotes)
https://stackoverflow.com/q/2082686/2446102 (174k views, ~150 upvotes)
Similar features are implemented in:
- SQL Server (as TRY_CONVERT)
- Oracle (as CONVERT([val] DEFAULT [expr] ON CONVERSION ERROR)
I would love to implement it myself, but my knowledge of C is superficial.
Thanks,
Michał Wadas
В списке pgsql-hackers по дате отправления: