<?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: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309576#M8843</link>
    <description />
    <pubDate>Sun, 06 Nov 2016 06:11:05 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-11-06T06:11:05Z</dc:date>
    <item>
      <title>SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309358#M8828</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a Postgres table with a serial column (autoincrement) and want to append new data to it using the DI Studio table loader.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Table Loader I leave the column mapping empty for the serial column (__screening_id) hoping that it will not be loaded so that Postgres can fill it in itself:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5658iE2F845632A6AB1D7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-11-04_17-57-36.png" title="2016-11-04_17-57-36.png" /&gt;&lt;/P&gt;&lt;P&gt;But that is not what is happening.&lt;/P&gt;&lt;P&gt;It generates a mapping for __screening_id as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  %put %str(NOTE: Mapping columns ...);
   proc sql;
      create view work.W5CY70T as
         select
            . as "__screening_id"n length = 8,
            "__screen_id"n,
            "__screening_job_run_id"n,
            "__screening_object"n,
            "__screening_dts"n,
            "__screening_result"n,
            "__screening_msg"n,
            "" as "__update_user"n length = 32
               format = $32.
               informat = $32.,
            . as "__update_dts"n length = 8
               format = DATETIME25.6
               informat = DATETIME25.6
      from &amp;amp;etls_lastTable
      ;
   quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then a proc append. This returns the following Postgres error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR: During insert: ERROR: null value in column "__screening_id" violates not-null constraint &lt;BR /&gt;Failing row contains (null, 5, null, WIKSTO.TAG_MEASURES_NUM_PI, 2016-11-04 17:18:00, PASSED, 0 rows passed, 0 rows failed, 0 screens passed, 0 screens failed, null, null).; Error while executing the query&lt;/PRE&gt;&lt;P&gt;How can I make this work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 17:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309358#M8828</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2016-11-04T17:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309455#M8834</link>
      <description>&lt;P&gt;I believe there is no option where you can exclude a target column from being part of the SQL, not sure though and may be there is somewhere a drop option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What should work is to have a "duplicate" table metadata object for loading where you remove&amp;nbsp;your auto increment column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 01:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309455#M8834</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-05T01:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309518#M8836</link>
      <description>Try IGNORE_READ_ONLY_COLUMNS=YES libname option.</description>
      <pubDate>Sat, 05 Nov 2016 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309518#M8836</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-11-05T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309547#M8841</link>
      <description>&lt;P&gt;I tested a duplicate metadata registration of the Postgres table without the SERIAL column (__screening_id).&lt;/P&gt;&lt;P&gt;This does not help (with proc append anyway), behind the scenes SAS queries the target table and generates Postgres SQL insert code for all columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;POSTGRES_49: Prepared: on connection 4
INSERT INTO "DQ_SCREENINGS"
("__screening_id","__screen_id","__screening_job_run_id","__screening_object","__screening_dts","__screening_result","__screenin
g_msg","__update_user","__update_dts")  VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested &lt;SPAN&gt;IGNORE_READ_ONLY_COLUMNS=YES, which also did not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It looks like SERIAL data type in Postgres is not read-only and so the libname engine does not recognize it as such.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I found does work is specifying the (drop=serial_column) table option on the output dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5673iAF1C9D69226A0576/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-11-06_01-04-49.png" title="2016-11-06_01-04-49.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The generated code is then:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   proc append base = WIKCNTL."DQ_SCREENINGS"n(drop=__screening_id)
      data = &amp;amp;etls_lastTable (&amp;amp;etls_tableOptions)  force ;
    run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But then this gives a warning (unacceptable in our batch) and I can't find a way to have the table loader add the NOWARN option to PROC APPEND.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any (other) ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2016 00:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309547#M8841</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2016-11-06T00:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309552#M8842</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I believe things could work if you use "Insert" instead of "Append" together with&amp;nbsp;&lt;/SPAN&gt;the approach of duplicate table metadata registration of the Postgres table without the SERIAL column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5674iC2BF7AB543097B17/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still worth trying what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH﻿&lt;/a&gt;&amp;nbsp;proposed and I'd be very curious if that works.&lt;/P&gt;
&lt;P&gt;- just read that you've tried this already.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2016 21:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309552#M8842</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-06T21:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309576#M8843</link>
      <description />
      <pubDate>Sun, 06 Nov 2016 06:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/309576#M8843</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-11-06T06:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DI Studio 4.901 Table Loader to load Postgres table with serial number</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/310143#M8887</link>
      <description>&lt;P&gt;I don't like the duplicate metadata registration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I built my own (very limited) table loader transformation to:&lt;/P&gt;&lt;P&gt;-&amp;nbsp;skip&amp;nbsp;unmapped columns&lt;/P&gt;&lt;P&gt;- optionally add the NOWARN option to PROC APPEND&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For what it's worth, the code I currently have (which will surely evolve when I find errors in it and need additional options).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro x;
 
  %let rc = 0;
  %if (&amp;amp;loadstyle = REPLACE_DROP) %then
  %do;
       %if (&amp;amp;_OUTPUT_engine. = SAS) %then
       %do;
            proc sql;
              drop table &amp;amp;_OUTPUT.;
            quit;
       %end;
       %else
       %do;
            %put ERROR: REPLACE_DROP is only allowed for SAS data sets.;
            %let rc = 4;
       %end;
  %end;
  %if (&amp;amp;loadstyle = REPLACE_DELETE) %then
  %do;
       proc sql;
         delete * from &amp;amp;_OUTPUT.;
       quit;
       %let rc = &amp;amp;sqlrc;
  %end;
  %if (&amp;amp;loadstyle = REPLACE_TRUNCATE) %then
  %do;
       %if (&amp;amp;_OUTPUT_engine. = POSTGRES) %then
       %do;
            data _null_;
              call symput('postgres_table',strip(scan(scan(symget('_OUTPUT'),2,'.'),1,'"')));
            run;
            %put NOTE: &amp;amp;=POSTGRES_TABLE;
            proc sql;
              connect to postgres (&amp;amp;_OUTPUT_connect);
              execute ( truncate "&amp;amp;POSTGRES_TABLE" ) by postgres;
              disconnect from postgres;
            quit;
            %let rc = &amp;amp;sqlrc;
       %end;
       %else
       %do;
            %put ERROR: REPLACE_TRUNCATE is only allowed for Postgres tables.;
            %let rc = 4;
       %end;
  %end;
  %if (&amp;amp;rc = 0) %then
  %do;
 
       proc datasets lib=WORK nolist nowarn;
         delete __LOAD;
       run;
       proc sql;
         create view WORK.__LOAD as
           select
           %let first = 1;
           %do i=0 %to %eval(&amp;amp;_OUTPUT_col_count. - 1);
                %if ((&amp;amp;&amp;amp;&amp;amp;_OUTPUT0_col&amp;amp;i._exp. ne ) or (&amp;amp;&amp;amp;&amp;amp;_OUTPUT0_col&amp;amp;i._input_count. &amp;gt; 0)) %then
                %do;
                     %if (&amp;amp;first. ne 1) %then , ;
                     %else %let first = 0;
                     %if       (&amp;amp;&amp;amp;&amp;amp;_OUTPUT0_col&amp;amp;i._exp.         ne ) %then &amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._exp;
                     %else %if (&amp;amp;&amp;amp;&amp;amp;_OUTPUT0_col&amp;amp;i._input_count. &amp;gt; 0) %then &amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._input;
                     as &amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._name
                     %if (&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._type.     =  $) %then length=&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._length.;
                     %if (&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._format.   ne  ) %then format=&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._format.;
                     %if (&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._informat. ne  ) %then informat=&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._informat.;
                     %if (&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._label.    ne  ) %then label="&amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._label.";
                %end;
           %end;
           from   &amp;amp;_INPUT
         ;
       quit;
       proc append base=&amp;amp;_OUTPUT.(
           %let first = 1;
           %do i=0 %to %eval(&amp;amp;_OUTPUT_col_count. - 1);
                %if ((&amp;amp;&amp;amp;&amp;amp;_OUTPUT0_col&amp;amp;i._exp. eq ) and (&amp;amp;&amp;amp;&amp;amp;_OUTPUT0_col&amp;amp;i._input_count. = 0)) %then
                %do;
                     %if (&amp;amp;first. = 1) %then
                     %do;
                          drop =
                          %let first = 0;
                     %end;
                     &amp;amp;&amp;amp;&amp;amp;_OUTPUT_col&amp;amp;i._name
                %end;
           %end;
                   )
                   data=WORK.__LOAD
                   %if (%upcase(&amp;amp;warn) = NOWARN) %then NOWARN;
                   ;
       run;
  %end;
%mend x;
options mprint;
%x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Nov 2016 16:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Studio-4-901-Table-Loader-to-load-Postgres-table-with/m-p/310143#M8887</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2016-11-08T16:25:32Z</dc:date>
    </item>
  </channel>
</rss>

