<?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: auto incremented, unique identifier in DB in Streaming Analytics</title>
    <link>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480761#M71</link>
    <description>&lt;P&gt;Patrick, thanks for your suggestions. The view tip might be the best workaround for this situation. &lt;BR /&gt;But I'm still interested if it is possible in the ESP model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In an plain insert statement, you specify the DEFAULT (or NULL) keyword for the serial column, for example:&lt;BR /&gt;INSERT INTO test (id, NAME)&lt;BR /&gt;VALUES(DEFAULT, '&lt;A href="http://www.postgresql.org" target="_blank"&gt;http://www.postgresql.org&lt;/A&gt;')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We tried to define the column in ESP with a value "DEFAULT", but that is not working.&lt;/P&gt;
&lt;P&gt;I will check with technical support if there is a way to accomplish this. I will let you know, if there is a way.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 11:19:47 GMT</pubDate>
    <dc:creator>Ebele</dc:creator>
    <dc:date>2018-07-24T11:19:47Z</dc:date>
    <item>
      <title>auto incremented, unique identifier in DB</title>
      <link>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480382#M69</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;From an ESP model we want to update a db table which has column defined as serial key (SERIAL PRIMARY KEY).&lt;BR /&gt;In this way postgres creates a auto incremented, unique identifier.&lt;/P&gt;
&lt;P&gt;How do we define this column in the ESP schema? &lt;BR /&gt;We've tried several options: to insert data into a DB table, ESP expects a field for each column in the schema.&lt;/P&gt;
&lt;P&gt;The functional window which writes the values to db looks like this:&lt;/P&gt;
&lt;P&gt;&amp;lt;window-functional pubsub="true" name="B03_Write_raw_sensor_data"&amp;gt;&lt;BR /&gt; &amp;lt;schema&amp;gt;&lt;BR /&gt; &amp;lt;fields&amp;gt;&lt;BR /&gt; &amp;lt;field name="raw_sensor_data_id" type="string"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="esp_id" type="int64" key="true"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="sensor_id" type="int64" key="true"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="sensor_status" type="string"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="sensor_status_description" type="string"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="phenomenom_time" type="date" key="true"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="value" type="double"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="unit" type="string"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="raw_sensor_output" type="string"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="load_time" type="date"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="sensor_metadata_id_from_sensor_metadata" type="int64"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="access_license_id_from_access_license" type="int64"/&amp;gt;&lt;BR /&gt; &amp;lt;field name="quantity" type="string" key="true"/&amp;gt;&lt;BR /&gt; &amp;lt;/fields&amp;gt;&lt;BR /&gt; &amp;lt;/schema&amp;gt;&lt;BR /&gt; &amp;lt;function-context&amp;gt;&lt;BR /&gt; &amp;lt;functions&amp;gt;&lt;BR /&gt; &amp;lt;function name="load_time"&amp;gt;&amp;lt;![CDATA[timeCurrent()]]&amp;gt;&amp;lt;/function&amp;gt;&lt;BR /&gt; &amp;lt;function name="access_license_id_from_access_license"&amp;gt;&amp;lt;![CDATA[1]]&amp;gt;&amp;lt;/function&amp;gt;&lt;BR /&gt; &amp;lt;function name="raw_sensor_data_id"&amp;gt;&amp;lt;![CDATA[concat(esp_id,sensor_id,phenomenom_time,quantity)]]&amp;gt;&amp;lt;/function&amp;gt;&lt;BR /&gt; &amp;lt;function name="sensor_metadata_id_from_sensor_metadata"&amp;gt;&amp;lt;![CDATA[sensor_metadata_id]]&amp;gt;&amp;lt;/function&amp;gt;&lt;BR /&gt; &amp;lt;/functions&amp;gt;&lt;BR /&gt; &amp;lt;/function-context&amp;gt;&lt;BR /&gt; &amp;lt;connectors&amp;gt;&lt;BR /&gt; &amp;lt;connector class="db" name="raw_sensor_data"&amp;gt;&lt;BR /&gt; &amp;lt;properties&amp;gt;&lt;BR /&gt; &amp;lt;property name="type"&amp;gt;&amp;lt;![CDATA[sub]]&amp;gt;&amp;lt;/property&amp;gt;&lt;BR /&gt; &amp;lt;property name="snapshot"&amp;gt;&amp;lt;![CDATA[false]]&amp;gt;&amp;lt;/property&amp;gt;&lt;BR /&gt; &amp;lt;property name="connectstring"&amp;gt;&amp;lt;![CDATA[DSN=lmw_tmp;uid=??;pwd=??;]]&amp;gt;&amp;lt;/property&amp;gt;&lt;BR /&gt; &amp;lt;property name="desttablename"&amp;gt;&amp;lt;![CDATA[@schema@.raw_sensor_data]]&amp;gt;&amp;lt;/property&amp;gt;&lt;BR /&gt; &amp;lt;/properties&amp;gt;&lt;BR /&gt; &amp;lt;/connector&amp;gt;&lt;BR /&gt; &amp;lt;/connectors&amp;gt;&lt;BR /&gt;&amp;lt;/window-functional&amp;gt;&lt;/P&gt;
&lt;P&gt;As a workaround now, we use a concatenation of several fields (concat(esp_id,sensor_id,phenomenom_time,quantity).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Postgres is the database, working with ESP 5.1.&lt;/P&gt;
&lt;P&gt;Ebele Veenstra&lt;BR /&gt;RWS&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 10:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480382#M69</guid>
      <dc:creator>Ebele</dc:creator>
      <dc:date>2018-07-23T10:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: auto incremented, unique identifier in DB</title>
      <link>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480692#M70</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18073"&gt;@Ebele&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I don't know much about ESP so can't answer you on this level.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for loading: You obviously can't load into an auto-increment column so you need to find a way to not have this column present for any inserts. If you can't manage this from the ESP side then one way to go would be loading via a view which doesn't have the column in it (or doesn't pass the value to the table for inserts).&lt;/P&gt;
&lt;P&gt;Another (less preferred) way would be to change the column type in the DB and go for an after insert trigger which auto increments the column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But may be it's just a "how to... ESP) challenge and there is a solution. Given that ESP is rather new I'd suggest you contact SAS TechSupport directly with this question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd be very interested to learn what the solution has been in the end.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 02:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480692#M70</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-07-24T02:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: auto incremented, unique identifier in DB</title>
      <link>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480761#M71</link>
      <description>&lt;P&gt;Patrick, thanks for your suggestions. The view tip might be the best workaround for this situation. &lt;BR /&gt;But I'm still interested if it is possible in the ESP model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In an plain insert statement, you specify the DEFAULT (or NULL) keyword for the serial column, for example:&lt;BR /&gt;INSERT INTO test (id, NAME)&lt;BR /&gt;VALUES(DEFAULT, '&lt;A href="http://www.postgresql.org" target="_blank"&gt;http://www.postgresql.org&lt;/A&gt;')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We tried to define the column in ESP with a value "DEFAULT", but that is not working.&lt;/P&gt;
&lt;P&gt;I will check with technical support if there is a way to accomplish this. I will let you know, if there is a way.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 11:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480761#M71</guid>
      <dc:creator>Ebele</dc:creator>
      <dc:date>2018-07-24T11:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: auto incremented, unique identifier in DB</title>
      <link>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480777#M72</link>
      <description>&lt;P&gt;When the connector requests the table field's attributes at initialisation, if a field is defined as read only (&amp;nbsp;SQL_ATTR_READONLY) then it automatically replace the value by "DEFAULT" in the INSERT statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now it would be interesting to look at&amp;nbsp;the ODBC attributes of your table, to see if this attribute is set on this field or if there is another attribute to consider and then enhance the connector.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;Fred&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 12:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Streaming-Analytics/auto-incremented-unique-identifier-in-DB/m-p/480777#M72</guid>
      <dc:creator>FredCombaneyre</dc:creator>
      <dc:date>2018-07-24T12:31:53Z</dc:date>
    </item>
  </channel>
</rss>

