Re: INSERT Trigger to check for existing records : Does this do what I hope it is doing?
От | Adrian Klaver |
---|---|
Тема | Re: INSERT Trigger to check for existing records : Does this do what I hope it is doing? |
Дата | |
Msg-id | 56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com обсуждение исходный текст |
Ответ на | Re: INSERT Trigger to check for existing records : Does this do what I hope it is doing? (Adrian Klaver <adrian.klaver@aklaver.com>) |
Список | pgsql-general |
On 11/25/20 9:13 AM, Adrian Klaver wrote: > On 11/25/20 8:43 AM, hagen@datasundae.com wrote: >> Adrian, >> > > Until the previous questions are addressed the above is not doable. > >> >> 3. Not positive the IF is doing what I want, but if I copy a >> sfdc.dealid into the same_test() parameter field the FUNTION does >> update the hygiene_119.status field properly. To me, it appears I just >> need a way to iterate through and insert one hygiene_119.dealid in >> the same_test parameter field. Then the UPDATE should flag all the >> hygiene_119 records as SAME or NEW. Obviously I don't REALLY need both >> flags as the absence of a flag would indicate status too. > > Before continuing with the function I would try some SELECT functions > that do what you want. > Would probably help if I expanded on that. So to find dealids that are new, something like: SELECT new_data.dealid FROM hygiene_119 AS new_data LEFT JOIN sfdc sp AS old_data ON new_data.dealid = old_data.dealid WHERE old_data.dealid IS NULL; The LEFT JOIN will return all the dealids from hygiene_119 and if a dealid does not exist in sfdc the fields for it will be set to NULL. So by filtering on old_data.dealid IS NULL you find the dealids that exist in the new data but not the old. >> Best, >> >> Hagen >> -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: