| From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> | 
|---|---|
| To: | Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: Me again with an insert trigger problem | 
| Date: | 2024-02-27 22:20:52 | 
| Message-ID: | f03929e9-4188-4b21-9f64-e7929d68933d@aklaver.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On 2/27/24 14:11, Thiemo Kellner wrote:
> 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.
create table true_test(id integer);
insert into true_test select * from generate_series(1, 10000);
select count(*) from true_test where true;
  count
-------
  10000
(1 row)
select count(*) from true_test where id < 100 and true;
  count
-------
     99
> 
>> 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!
> 
> 
-- 
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thiemo Kellner | 2024-02-27 22:38:54 | Re: Me again with an insert trigger problem | 
| Previous Message | Thiemo Kellner | 2024-02-27 22:11:08 | Re: Me again with an insert trigger problem |