pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: hagen@datasundae.com
To: pgsql-general@lists.postgresql.org
Subject: Re: INSERT Trigger to check for existing records : Does this do what I hope it is doing?
Date: Wed, 25 Nov 2020 09:43:36 -0800
Message-ID: <56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com> (raw)
In-Reply-To: <5d6937c6-d34d-91b1-6fe7-81a9ef2007ed@aklaver.com>
References: <CAKoxK+5x9J74Sn=rvGSu4dAkSdpF=9AoTjs9-KmnSGd6c03SxQ@mail.gmail.com>
	<1fc1fb9e-684f-d028-3f9b-fcfaf1f12f65@aklaver.com>
	<CAKoxK+4DGFeevYrCJ3oEWxqXGodtEKt33dpQQjvw0O1ZwMgWyA@mail.gmail.com>
	<3e1051a4-98d4-4a59-f382-5b82efa4c095@datasundae.com>
	<CAKFQuwYpbAQ-rm++roXFiQdP-OmX4Wwzmnh1U2qWSpRAG_LbJA@mail.gmail.com>
	<f38a05da-48d8-1f95-78a4-159414424ec3@datasundae.com>
	<CAKFQuwZQXdHJ=Maf6FgSnP3SZdn9jQtLb7qXR6_vrzioJXbnRg@mail.gmail.com>
	<CAKFQuwZK_igf_c2CuEUWC-VAYxHeR1+PAfTtATzTJZX5836wFA@mail.gmail.com>
	<000e01d6c036$fda479b0$f8ed6d10$@datasundae.com>
	<CAHOFxGo9etLxf=ZmgNKfsZ1jnNo8OWcvx24520oQpqHo86BMYw@mail.gmail.com>
	<2ecce3f7-f298-7fd2-f470-5cf9a71b349c@datasundae.com>
	<4131ec0f-7dfa-d170-8312-d4fa3fc7ec0f@aklaver.com>
	<204a1ad6-fd56-fa19-2211-cde267810b92@datasundae.com>
	<d7c2cf5b-d100-01d8-7e2e-d57a144420df@datasundae.com>
	<bd684492-4c61-9b93-5ac0-253defc6acbb@aklaver.com>
	<07cf01d6c34a$157bf610$4073e230$@datasundae.com>
	<5d6937c6-d34d-91b1-6fe7-81a9ef2007ed@aklaver.com>

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





view thread (22+ messages)

Message-ID: <56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com>
Permalink:  ../56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com/
Also on:    postgresql.org/message-id/56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, hagen@datasundae.com
  Subject: Re: INSERT Trigger to check for existing records : Does this do what I hope it is doing?
  In-Reply-To: <56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com>
  References: <CAKoxK+5x9J74Sn=rvGSu4dAkSdpF=9AoTjs9-KmnSGd6c03SxQ@mail.gmail.com> <CAKoxK+4DGFeevYrCJ3oEWxqXGodtEKt33dpQQjvw0O1ZwMgWyA@mail.gmail.com> <3e1051a4-98d4-4a59-f382-5b82efa4c095@datasundae.com> <CAKFQuwYpbAQ-rm++roXFiQdP-OmX4Wwzmnh1U2qWSpRAG_LbJA@mail.gmail.com> <f38a05da-48d8-1f95-78a4-159414424ec3@datasundae.com> <CAKFQuwZQXdHJ=Maf6FgSnP3SZdn9jQtLb7qXR6_vrzioJXbnRg@mail.gmail.com> <CAKFQuwZK_igf_c2CuEUWC-VAYxHeR1+PAfTtATzTJZX5836wFA@mail.gmail.com> <000e01d6c036$fda479b0$f8ed6d10$@datasundae.com> <CAHOFxGo9etLxf=ZmgNKfsZ1jnNo8OWcvx24520oQpqHo86BMYw@mail.gmail.com> <2ecce3f7-f298-7fd2-f470-5cf9a71b349c@datasundae.com> <4131ec0f-7dfa-d170-8312-d4fa3fc7ec0f@aklaver.com> <204a1ad6-fd56-fa19-2211-cde267810b92@datasundae.com> <d7c2cf5b-d100-01d8-7e2e-d57a144420df@datasundae.com> <bd684492-4c61-9b93-5ac0-253defc6acbb@aklaver.com> <07cf01d6c34a$157bf610$4073e230$@datasundae.com> <5d6937c6-d34d-91b1-6fe7-81a9ef2007ed@aklaver.com> <56dd17d9-eadb-df56-4df6-ba79e4bcc3ca@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox