# Cannot Save Form Data

**URL:** <https://forum.servoy.com/t/cannot-save-form-data/13257>\
**Category:** Classic Servoy\
**Created:** [December 1, 2010, 4:43pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257 "2010-12-01T16:43:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [December 1, 2010, 4:43pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/1 "2010-12-01T16:43:51Z")

</div>

Since switching to Postgres, I have gone through our database tables and fixed primary keys that were based on text fields to use integer fields. That went smoothly. We did have a few tables that were already using integers for pk’s so not maintenance was necessary. We have a table that stores images we use for buttons. This was one of the tables I didn’t have to mess with. I know I’ve added rows to this table since the database switch, but for some reason today when I try to add a new record I get this error:

```auto
Cannot save form data
 > com.servoy.j2db.dataprocessing.DataException: ERROR: duplicate key value violates unique constraint "buttons_pkey"

```

Here is a copy of my server log:

```auto
2010-12-01 10:07	AWT-EventQueue-0	ERROR	com.servoy.j2db.util.Debug	Throwable

com.servoy.j2db.ApplicationException: Cannot save form data 
    	at com.servoy.j2db.dataprocessing.EditRecordList.stopEditing(EditRecordList.java:598) 
    	at com.servoy.j2db.dataprocessing.EditRecordList.stopEditing(EditRecordList.java:165) 
    	at com.servoy.j2db.smart.dataui.DataRenderer$1.mouseReleased(DataRenderer.java:112) 
    	at java.awt.Component.processMouseEvent(Unknown Source) 
    	at javax.swing.JComponent.processMouseEvent(Unknown Source) 
    	at java.awt.Component.processEvent(Unknown Source) 
    	at java.awt.Container.processEvent(Unknown Source) 
    	at java.awt.Component.dispatchEventImpl(Unknown Source) 
    	at java.awt.Container.dispatchEventImpl(Unknown Source) 
    	at java.awt.Component.dispatchEvent(Unknown Source) 
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
    	at java.awt.Container.dispatchEventImpl(Unknown Source) 
    	at java.awt.Window.dispatchEventImpl(Unknown Source) 
    	at java.awt.Component.dispatchEvent(Unknown Source) 
    	at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    	at java.awt.EventDispatchThread.run(Unknown Source) 
    Caused by: com.servoy.j2db.dataprocessing.DataException: ERROR: duplicate key value violates unique constraint "buttons_pkey" 
    	at com.servoy.j2db.dblayer.Zb.Za(Zb.java:119) 
    	at com.servoy.j2db.server.Zc.Zo.Za(Zo.java:442) 
    	at com.servoy.j2db.dataprocessing.Zu.performUpdates(Zu.java:396) 
    	at com.servoy.j2db.dataprocessing.EditRecordList.stopEditing(EditRecordList.java:464) 
    	... 22 more

2010-12-01 10:07	AWT-EventQueue-0	ERROR	com.servoy.j2db.util.Debug	Error executing sql: insert into buttons (bgcolor, fgcolor, enabled, tooltiptext, transparent, visible, buttonname, font, bgcolor_field, mainimagehtml, mainimage, pressedimage, pressedimagehtml, mainimageurl, mainimagecalc) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) with params: [NullValue with type: 12 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 12 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 4 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 12 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 4 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 4 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 12 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 12 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: 12 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, '<html><head></head><body><p style="margin-top: 0"><img src="media:///servoy_blobloader?servername=eclinic&tablename=buttons&dataprovider=mainimage&rowid=DbIdentValue26222912"></p></body></html>' ,type: java.lang.String, NullValue with type: -2 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, NullValue with type: -2 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue, '<html><head></head><body><p style="margin-top: 0"><img src="media:///servoy_blobloader?servername=eclinic&tablename=buttons&dataprovider=pressedimage&rowid=DbIdentValue26222912"></p></body></html>' ,type: java.lang.String, 'media:///servoy_blobloader?servername=eclinic&tablename=buttons&dataprovider=mainimage&rowid=DbIdentValue26222912' ,type: java.lang.String, NullValue with type: -2 ,type: com.servoy.j2db.dataprocessing.ValueFactory$NullValue]

org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "buttons_pkey" 
    	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525) 
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309) 
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188) 
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452) 
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354) 
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:308) 
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    	at java.lang.reflect.Method.invoke(Unknown Source) 
    	at com.servoy.j2db.Za.Za.Zf.invoke(Zf.java:15) 
    	at $Proxy1.executeUpdate(Unknown Source) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
    	at com.servoy.j2db.dataprocessing.Zu.performUpdates(Zu.java:933) 
    	at com.servoy.j2db.dataprocessing.EditRecordList.stopEditing(EditRecordList.java:464) 
    	at com.servoy.j2db.dataprocessing.EditRecordList.stopEditing(EditRecordList.java:165) 
    	at com.servoy.j2db.smart.dataui.DataRenderer$1.mouseReleased(DataRenderer.java:112) 
    	at java.awt.Component.processMouseEvent(Unknown Source) 
    	at javax.swing.JComponent.processMouseEvent(Unknown Source) 
    	at java.awt.Component.processEvent(Unknown Source) 
    	at java.awt.Container.processEvent(Unknown Source) 
    	at java.awt.Component.dispatchEventImpl(Unknown Source) 
    	at java.awt.Container.dispatchEventImpl(Unknown Source) 
    	at java.awt.Component.dispatchEvent(Unknown Source) 
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
    	at java.awt.Container.dispatchEventImpl(Unknown Source) 
    	at java.awt.Window.dispatchEventImpl(Unknown Source) 
    	at java.awt.Component.dispatchEvent(Unknown Source) 
    	at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    	at java.awt.EventDispatchThread.run(Unknown Source)

```

We’re using Servoy 5.2.1 and Postgres 8.4. Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [December 1, 2010, 9:57pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/2 "2010-12-01T21:57:57Z")

</div>

Hi Nicholas,

The error means that your primary key column already holds the value you try to insert as PK.  
What do you see as sequence type in the view of this table in servoy ? Dbidentity or Servoy Sequence or something else ?

---

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [December 2, 2010, 3:08pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/3 "2010-12-02T15:08:03Z")

</div>

The sequence is set to DB Identity. I haven’t changed anything with this table so I’m not sure why it’s telling me that the value already exists. The last record in the table has a pk of 193. Is there a way for me to set the sequence to pick up at 194?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [December 2, 2010, 4:05pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/4 "2010-12-02T16:05:47Z")

</div>

Hi Nicholas,

You can edit the database sequence via the DBA tool PgAdmin. Just see what sequence name it uses on the table (see default value of the PK column) and edit that sequence.

---

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [December 7, 2010, 10:50pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/5 "2010-12-07T22:50:04Z")

</div>

Hi Robert,

The default value for the pk in my buttons table is _nextval(‘buttons\_buttonsid\_seq’::regclass)_. This may be a stupid question, but how do I set the sequence to start at 194?

Thanks.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [December 8, 2010, 6:09am UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/6 "2010-12-08T06:09:11Z")

</div>

Hi Nicholas,

nextval(‘buttons\_buttonsid\_seq’::regclass) means the sequence name is “buttons\_buttonsid\_seq”.  
When you connect PgAdmin to your PostgreSQL server you see the object tree on the left. Just expand the node of your database and you will see the following:[attachment=1]objecttree.png[/attachment]

Open the sequences node here and you will see the buttons\_buttonsid\_seq sequence in the list. Right click on it to edit it.  
Then you get the following dialog:[attachment=0]sequence\_edit.png[/attachment]  
Here you set the current value field to 194.  
Hit the OK button and you are done.

Another option would be to use the commandline editor (psql) and use the following SQL:

```auto
ALTER SEQUENCE buttons_buttonsid_seq RESTART WITH 194;

```

See [http://www.postgresql.org/docs/9.0/stat … uence.html](http://www.postgresql.org/docs/9.0/static/sql-altersequence.html) for more on this command.

Hope this helps.

 ![sequence_edit.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/0/047b6dcdf9dee3ded7478b6cf6d273667d26d316.png)

 ![objecttree.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/6/69394a25c35fad809c0650994ff2c325b82d8f2d.png)

---

<div class="post-metadata">

**Author:** ![gldni](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gldni](https://forum.servoy.com/u/gldni)\
**Post date:** [December 13, 2010, 5:30pm UTC](https://forum.servoy.com/t/cannot-save-form-data/13257/7 "2010-12-13T17:30:19Z")

</div>

Robert again to save the day!

Thanks!
