| От | Tom Lane |
|---|---|
| Тема | Re: Null function parameters |
| Дата | |
| Msg-id | 9387.966964520@sss.pgh.pa.us обсуждение |
| Ответ на | Null function parameters ("Graham Vickrage" <graham@digitalplanit.com>) |
| Список | pgsql-sql |
"Graham Vickrage" <graham@digitalplanit.com> writes:
> However my understanding was that if the default value is SQL NULL then any
> values passed into the function that are null would be treated as 'NULL'.
Not sure what you think you meant by that, but a null is a null. If you
declared the table column as NOT NULL then Postgres is doing exactly
what it should. You may wish to code the insert along the lines of
INSERT INTO table VALUES (..., COALESCE($1, suitable-default), ...)
COALESCE is a handy notation for "value1 unless it's NULL, in which case
value2".
regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера