Re: Me again with an insert trigger problem

Поиск
Список
Период
Сортировка
От Thiemo Kellner
Тема Re: Me again with an insert trigger problem
Дата
Msg-id d56f1205-ff78-42f6-8735-25c5129b1ffa@gelassene-pferde.biz
обсуждение исходный текст
Ответ на Me again with an insert trigger problem  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
Ответы Re: Me again with an insert trigger problem
Список pgsql-general
Am 27.02.2024 um 21:42 schrieb Adrian Klaver:
> Also not sure what this:
> 
> select NODE_TYPE⠒NAME into V⠒NODE_TYPE⠒NAME
>                from NODE⠒V
>               where 1 = 1
>                 and ID = new.NODE⠒ID
>                 and 1 = 1;
> 
> is supposed to be doing especially the 1 = 1 tests?

The select retrieves the type of the node in order to determine whether 
a task name must be given or not.

It is a habit of mine to pad conditions in the where clause. This way, 
it is easy to comment/uncomment parts of the clause for testing 
purposes. Coming from Oracle, I missed that using "true" is also 
possible and better because clearer.

> Seems  '... where  ID = new.NODE⠒ID ...' is sufficient.

Right. Semantically sufficient.


> Also what do you want to return as NEW?

The unchanged new record. And it works as intended.

Thanks for your help!



В списке pgsql-general по дате отправления:

Предыдущее
От: Jason Long
Дата:
Сообщение: Re: PostgreSQL Guard
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Me again with an insert trigger problem