| От | Richard Huxton |
|---|---|
| Тема | Re: Altering built-in functions cast |
| Дата | |
| Msg-id | 430ED0B3.7040604@archonet.com обсуждение исходный текст |
| Ответ на | Altering built-in functions cast ("Matt A." <survivedsushi@yahoo.com>) |
| Ответы |
Re: Altering built-in functions cast
|
| Список | pgsql-general |
Matt A. wrote:
> Anyone know how I could alter the cast of the nullif()
> function directly to return INT?
>
> We use NULLIF() for adding [1|0|null] according to the
> evalution of nullif('x','') into integer columns.
> Where x is an integer and sometimes a empty string,
> which if it's an empty string (x='') then we add NULL
> cause NULLIF says if '' == '' then return NULL
Just add a wrapper function:
CREATE FUNCTION nullif_always_int(text) RETURNS integer AS '
SELECT nullif($1,'''')::int;
' LANGUAGE SQL;
--
Richard Huxton
Archonet Ltd
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера