<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ERROR When Updating POSTGRES TABLE using SAS DATASET in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766812#M243047</link>
    <description>&lt;P&gt;To combine data this data must be available on the server where the "join" needs to happen. In your case that's Postgres and though you need to first load your SAS table to Postgres.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;I can’t load the Work table because of the data protection policy&lt;/EM&gt;.&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;It's possible that you can't create a new table in the core schema. It's hopefully still possible to load into a temporary Postgres table - which SAS supports. If that's not possible then you need to talk to your DBA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The link &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm" target="_self"&gt;here&lt;/A&gt; should get you started. Follow the steps for&amp;nbsp;&lt;EM&gt;Pushing Updates&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once loading into a temporary table works I'd also strongly recommend that you revisit your SQL. If you Google for SQL to update a table with another table you will find examples with much simpler code that will also perform much better. A sub-select for every single column is just awfully inefficient.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 11:30:33 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-09-09T11:30:33Z</dc:date>
    <item>
      <title>ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766731#M243013</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had asked a similar question, where the table was getting into the update query which was solved by adding DBDIRECTEXEC to the Autoexec files. But this time while updating I'm facing another issue.&lt;/P&gt;&lt;P&gt;When I am trying to update the Postgres table with a SAS dataset (WORK.W25P3TOZ)&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting the below error:&lt;/P&gt;&lt;DIV class="sasError"&gt;ERROR: CLI execute error: ERROR: relation "work.w25p3toz" does not exist;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Error while executing the query.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;I have made sure the Data length and type match with the Postgres table.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;I remember I have updated the oracle tables using the Pass-thru facility and libname.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Here the Libname facility doesn't work and keeps running for ages and after completion of the update query or canceling the query&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;No message is displayed nor any Error is displayed.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;but when I try to create the Work, w25p3toz dataset on the schema the update works.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;I also tried updating the Postgres table using the SAS data step update, but it didn't work.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Can any of the Experts suggest to me how do I update the Postgres table from a SAS Dataset?&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;&lt;BR /&gt;connect to postgres as PSTGRE1&lt;BR /&gt;(server="xxxxxxxxxxx.abcdefghik.in-south-1.rds.amazonaws.com" &lt;BR /&gt;database="yyyyyyyy" user="lllllll" password="XyuIkIOILJM&amp;lt;" &lt;BR /&gt;connection=global);&lt;BR /&gt;execute&lt;BR /&gt;(update CORE.FSC_PARTY_DIM as m set &lt;BR /&gt;party_date_of_birth=(select party_date_of_birth from WORK.W25P3TOZ as t &lt;BR /&gt;where m.party_key=t.party_key), residence_country_code=(select &lt;BR /&gt;residence_country_code from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), citizenship_country_code=(select &lt;BR /&gt;citizenship_country_code from WORK.W25P3TOZ as t &lt;BR /&gt;where m.party_key=t.party_key), org_country_of_business_code=(select &lt;BR /&gt;org_country_of_business_code from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), email_address=(select email_address from &lt;BR /&gt;WORK.W25P3TOZ as t where m.party_key=t.party_key), &lt;BR /&gt;phone_number_1=(select phone_number_1 from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), phone_number_2=(select phone_number_2 from &lt;BR /&gt;WORK.W25P3TOZ as t where m.party_key=t.party_key), &lt;BR /&gt;phone_number_3=(select phone_number_3 from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), occupation_desc=(select occupation_desc from &lt;BR /&gt;WORK.W25P3TOZ as t where m.party_key=t.party_key), &lt;BR /&gt;party_type_desc=(select party_type_desc from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), party_tax_id=(select party_tax_id from &lt;BR /&gt;WORK.W25P3TOZ as t where m.party_key=t.party_key), &lt;BR /&gt;party_identification_id=(select party_identification_id from &lt;BR /&gt;WORK.W25P3TOZ as t where m.party_key=t.party_key), &lt;BR /&gt;party_identification_type_desc=(select party_identification_type_desc &lt;BR /&gt;from WORK.W25P3TOZ as t where m.party_key=t.party_key), &lt;BR /&gt;party_id_state_code=(select party_id_state_code from WORK.W25P3TOZ as t &lt;BR /&gt;where m.party_key=t.party_key), customer_since_date=(select &lt;BR /&gt;customer_since_date from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), doing_business_as_name=(select &lt;BR /&gt;doing_business_as_name from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), ultimate_parent_name=(select &lt;BR /&gt;ultimate_parent_name from WORK.W25P3TOZ as t where &lt;BR /&gt;m.party_key=t.party_key), party_name=(select party_name from &lt;BR /&gt;WORK.W25P3TOZ as t where m.party_key=t.party_key)&lt;BR /&gt;WHERE exists (select * from WORK.W25P3TOZ t WHERE &lt;BR /&gt;m.party_key=t.party_key)) by PSTGRE1;&lt;BR /&gt;disconnect from PSTGRE1;&lt;BR /&gt;Quit;&lt;BR /&gt; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 23:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766731#M243013</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2021-09-08T23:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766750#M243024</link>
      <description>&lt;P&gt;All the code in green is run by POSTGRES, the code in blue is run by SAS.&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#0000FF"&gt;proc sql;
connect to postgres as PSTGRE1
(server="xxxxxxxxxxx.abcdefghik.in-south-1.rds.amazonaws.com" 
database="yyyyyyyy" user="lllllll" password="XyuIkIOILJM&amp;lt;" 
connection=global);
execute
(&lt;FONT color="#339966"&gt;update CORE.FSC_PARTY_DIM as m set 
party_date_of_birth=(select party_date_of_birth from WORK.W25P3TOZ as t 
where m.party_key=t.party_key), residence_country_code=(select 
residence_country_code from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), citizenship_country_code=(select 
citizenship_country_code from WORK.W25P3TOZ as t 
where m.party_key=t.party_key), org_country_of_business_code=(select 
org_country_of_business_code from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), email_address=(select email_address from 
WORK.W25P3TOZ as t where m.party_key=t.party_key), 
phone_number_1=(select phone_number_1 from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), phone_number_2=(select phone_number_2 from 
WORK.W25P3TOZ as t where m.party_key=t.party_key), 
phone_number_3=(select phone_number_3 from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), occupation_desc=(select occupation_desc from 
WORK.W25P3TOZ as t where m.party_key=t.party_key), 
party_type_desc=(select party_type_desc from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), party_tax_id=(select party_tax_id from 
WORK.W25P3TOZ as t where m.party_key=t.party_key), 
party_identification_id=(select party_identification_id from 
WORK.W25P3TOZ as t where m.party_key=t.party_key), 
party_identification_type_desc=(select party_identification_type_desc 
from WORK.W25P3TOZ as t where m.party_key=t.party_key), 
party_id_state_code=(select party_id_state_code from WORK.W25P3TOZ as t 
where m.party_key=t.party_key), customer_since_date=(select 
customer_since_date from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), doing_business_as_name=(select 
doing_business_as_name from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), ultimate_parent_name=(select 
ultimate_parent_name from WORK.W25P3TOZ as t where 
m.party_key=t.party_key), party_name=(select party_name from 
WORK.W25P3TOZ as t where m.party_key=t.party_key)
WHERE exists (select * from &lt;STRONG&gt;WORK.W25P3TOZ&lt;/STRONG&gt; t WHERE 
m.party_key=t.party_key)&lt;/FONT&gt;) by PSTGRE1;
disconnect from PSTGRE1;
Quit;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;The message is quite clear:&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ERROR: relation "work.w25p3toz" does not exist;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either upload the SAS table or rework your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your code is awfully (un)formatted and impossible to read.&lt;/P&gt;
&lt;P&gt;Also I hope that's not your real password.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 01:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766750#M243024</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-09T01:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766759#M243029</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply!!!&lt;BR /&gt;Yes, the connection details provided here are mocked.&lt;BR /&gt;I can see the SAS dataset which is created by the SAS program. I m not sure how can this be not accessible to the Pass thru. I can’t load the Work table because of the data protection policy.&lt;BR /&gt;&lt;BR /&gt;I am trying to run the SAS DI studio code on SAS Studio.&lt;BR /&gt;&lt;BR /&gt;I m not sure if anyone else has faced the same issue.</description>
      <pubDate>Thu, 09 Sep 2021 03:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766759#M243029</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2021-09-09T03:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766762#M243030</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The table work.w25p3toz has to be a Postgres table as you are using SQL Passthru. Anything in the Passthru statement runs only in Postgres so will have no knowledge of SAS tables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To load a SAS table in Postgres you need to run either use SAS SQL or SAS code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 04:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766762#M243030</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-09-09T04:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766771#M243033</link>
      <description>&lt;P&gt;If you need to use a SAS table as an update for a remote DBMS table, you either have to upload the SAS table and do the update in the pass-through, or try to do the update without explicit pass-through and hope that SAS can push most of the processing to the DBMS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 06:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766771#M243033</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-09T06:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766778#M243036</link>
      <description>&lt;P&gt;The issue is really simple: the data must be available where the code runs.&lt;/P&gt;
&lt;P&gt;All the code that runs in POSTGRES must be able to see the data it processes. Likewise for the code that runs in SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;POSTGRES does not see SAS's WORK library.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 08:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766778#M243036</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-09T08:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766812#M243047</link>
      <description>&lt;P&gt;To combine data this data must be available on the server where the "join" needs to happen. In your case that's Postgres and though you need to first load your SAS table to Postgres.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;I can’t load the Work table because of the data protection policy&lt;/EM&gt;.&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;It's possible that you can't create a new table in the core schema. It's hopefully still possible to load into a temporary Postgres table - which SAS supports. If that's not possible then you need to talk to your DBA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The link &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm" target="_self"&gt;here&lt;/A&gt; should get you started. Follow the steps for&amp;nbsp;&lt;EM&gt;Pushing Updates&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once loading into a temporary table works I'd also strongly recommend that you revisit your SQL. If you Google for SQL to update a table with another table you will find examples with much simpler code that will also perform much better. A sub-select for every single column is just awfully inefficient.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 11:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/766812#M243047</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-09-09T11:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/767139#M243167</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time and valuable suggestions.&lt;/P&gt;&lt;P&gt;Now I have created a table on Postgres, and I am able to update the Pty_dim Postgres table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Santtosh...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 21:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/767139#M243167</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2021-09-10T21:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR When Updating POSTGRES TABLE using SAS DATASET</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/767167#M243177</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183704"&gt;@Santt0sh&lt;/a&gt;&amp;nbsp;That's good to hear. Please mark the answer that's the solution/helped you most as solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a side remark: Isn't the pty table a SCD2 table? And if so wouldn't you need to INSERT a new row if any of the columns you change are under SCD2 change tracking - and expire the current record by updating columns valid_to_dttm and change_current_ind?&lt;/P&gt;</description>
      <pubDate>Sat, 11 Sep 2021 02:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-When-Updating-POSTGRES-TABLE-using-SAS-DATASET/m-p/767167#M243177</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-09-11T02:29:43Z</dc:date>
    </item>
  </channel>
</rss>

