# Comment Panel Postgres

**URL:** <https://forum.inductiveautomation.com/t/comment-panel-postgres/2959>\
**Category:** Ignition\
**Created:** [May 20, 2011, 7:42pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959 "2011-05-20T19:42:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Mendonca](https://avatars.discourse-cdn.com/v4/letter/j/58f4c7/32.png) [@Joseph\_Mendonca](https://forum.inductiveautomation.com/u/Joseph_Mendonca)\
**Post date:** [May 20, 2011, 7:42pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/1 "2011-05-20T19:42:04Z")

</div>

Anything unique with Postgres? I can’t get insert 1 to work on the comments panel.

Insert 1

INSERT INTO notes (note, whoId, tstamp, attachment, filename, sticky) VALUES (?, %s, CURRENT\_TIMESTAMP, ?, ?, ?)

GatewayException: Gateway Error 301: SQL error for “INSERT INTO Notes (Note, WhoId, TStamp, Attachment, Filename, Sticky) VALUES (?, (SELECT Id FROM Users WHERE Username=‘admin’), CURRENT\_TIMESTAMP, ?, ?, ?)”: Returning autogenerated keys is not supported.  
caused by PSQLException: Returning autogenerated keys is not supported.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [May 20, 2011, 8:03pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/2 "2011-05-20T20:03:27Z")

</div>

How are the columns defined in the table?

---

<div class="post-metadata">

**Author:** ![Joseph\_Mendonca](https://avatars.discourse-cdn.com/v4/letter/j/58f4c7/32.png) [@Joseph\_Mendonca](https://forum.inductiveautomation.com/u/Joseph_Mendonca)\
**Post date:** [May 20, 2011, 8:22pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/3 "2011-05-20T20:22:26Z")

</div>

id = int primary key  
whoid= charvar  
tstamp=timestamp without time zone  
note=charvar  
filename=charvar  
sticky=boollean

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [May 20, 2011, 8:28pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/4 "2011-05-20T20:28:50Z")

</div>

When the comments panel does it's Insert into the database it is basically calling the system.db.runPrepUpdate() which has the option to return an auto-generated key value that's created as a result of the update completing successfully. Postgres appears to not support the returning of auto-generated keys (as the error message is stating).

As of now the comments panel is not going to work with Postgres. I'll put in a ticket to have this looked at and see if we can re-factor it in some way that allows the comment panel to be used with Postgres in the future.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [May 20, 2011, 10:19pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/5 "2011-05-20T22:19:31Z")

</div>

Postgres does not return autogenerated keys. Mainly because it does not support an autogenerated datatype. More info [here](http://www.postgresql.org/docs/8.3/interactive/datatype-numeric.html).

What you have to do in this case is to select currval() on the sequence name.  
Or use a returning clause on the insert statement as discussed [here](http://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id).

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 17, 2011, 12:20am UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/6 "2011-06-17T00:20:07Z")

</div>

As of 7.2.7 if you clear out query2, then the comments panel will not run the insert query with the request keys flag, which will let the component work on postgres.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [June 17, 2011, 3:41pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/7 "2011-06-17T15:41:13Z")

</div>

> [@](#):
>
> Postgres does not return autogenerated keys.

Actually, that's not really true any more. It's true that it doesn't have an "autogenerated datatype" per se, but I know for a fact that the new JDBC driver will return generated keys, at least when using the "serial" type (which isn't really a type, but a shortcut to create a sequence and use it for the column).

If you try upgrading the Postgres JDBC driver as described in the [other post](http://www.inductiveautomation.com/forum/viewtopic.php?f=72&t=6558) recently on postgres, you might have better luck.

Regards,

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [June 17, 2011, 5:40pm UTC](https://forum.inductiveautomation.com/t/comment-panel-postgres/2959/8 "2011-06-17T17:40:44Z")

</div>

I stand corrected. As you say, it’s a new thing.
