# Upsert error

**URL:** <https://discuss.aerospike.com/t/upsert-error/488>\
**Category:** Java Client\
**Created:** [November 4, 2014, 11:39am UTC](https://discuss.aerospike.com/t/upsert-error/488 "2014-11-04T11:39:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![josegom](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@josegom](https://discuss.aerospike.com/u/josegom)\
**Post date:** [November 4, 2014, 11:39am UTC](https://discuss.aerospike.com/t/upsert-error/488/1 "2014-11-04T11:39:58Z")

</div>

Hello,

I am trying to update a bin inserting other bin with the same PK.

I am using java client version 3.0.31 and aerospike community server version 3.3.22.

If the bin to update is an Integer the update operation add the column value to the previous column value. For example

in aql:

aql\> select \* from catalog\_functional\_test.assimpleinserttest ±---------+ | column\_2 | ±---------+ | 6 | ±---------+

With java code I insert a bin with the same PK and column\_2 value is equal to 8.

Again in aql:

aql\> select \* from catalog\_functional\_test.assimpleinserttest ±---------+ | column\_2 | ±---------+ | 14 | ±---------+

If the column\_2 is a String column the result is the following exception:

com.aerospike.client.AerospikeException: Error Code 12: Bin type error at com.aerospike.client.command.WriteCommand.parseResult(WriteCommand.java:59) at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:56) at com.aerospike.client.AerospikeClient.add(AerospikeClient.java:360).

Could somebody help me?

Thank you.

---

<div class="post-metadata">

**Author:** ![wchu](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wchu](https://discuss.aerospike.com/u/wchu)\
**Post date:** [November 5, 2014, 11:53am UTC](https://discuss.aerospike.com/t/upsert-error/488/2 "2014-11-05T11:53:22Z")

</div>

It looks like you are building up an Aerospike.operate() sequence on the record. Can you give the code which constructs the “operate()” call?

---

<div class="post-metadata">

**Author:** ![josegom](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@josegom](https://discuss.aerospike.com/u/josegom)\
**Post date:** [November 5, 2014, 12:32pm UTC](https://discuss.aerospike.com/t/upsert-error/488/3 "2014-11-05T12:32:25Z")

</div>

Hello,

I am using the add method from the java api.

The first time I invoke: aerospikeClient.add(writePolicy, key, bins);

With this parameters: writePolicy → writePolicy.recordExistsAction = RecordExistsAction.UPDATE; key → new Key(“catalog\_functional\_test”, assimpleinserttest, “1”) bins–\> [column\_2:6]

The second time I invoke the same api method with this parameters: writePolicy → writePolicy.recordExistsAction = RecordExistsAction.UPDATE; key → new Key(“catalog\_functional\_test”, assimpleinserttest, “1”) bins–\> [column\_2:8]

I don’t use the operate api method.

Thanks.

---

<div class="post-metadata">

**Author:** ![helipilot50](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/helipilot50/32/59_2.png) [@helipilot50](https://discuss.aerospike.com/u/helipilot50)\
**Post date:** [November 5, 2014, 1:53pm UTC](https://discuss.aerospike.com/t/upsert-error/488/4 "2014-11-05T13:53:50Z")

</div>

Hi,

The “add” operation increments or decrements an Integer Bin value by the amount that you pass as a parameter.

Assuming that the initial value is zero, after your firs invocation, the value of the Bin would be 6 (0 + 6 = 6). After the second invocation the value of the Bin would be 14 (6 + 8 = 14).

You cannot increment a String Bin. If you want to change the Bin type from String to Integer, you use “put” operation to over write the Bin with the new type and value.

Does this help?
