You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "olg.kpln@gmail.com" <ol...@gmail.com> on 2018/07/26 14:16:48 UTC

INSERT query that UPDATES if record already found

Hi There,
I'm using Ignite 2.4 with JDBC mainly as an in mem Cache and looking for a
way to write the fastest query to insert new record but if a record with the
same key already exists I would like it to be updated.

DDL looks like this:
CREATE TABLE PERSON (
  Id VARCHAR,
  name VARCHAR,
  PRIMARY KEY (id))
  WITH
"template=partitioned,WRITE_SYNCHRONIZATION_MODE=FULL_ASYNC,affinitykey=id,key_type=java.lang.String,value_type=java.temp.Person,
CACHE_NAME=Person";

Quries looks like this:
INSERT INTO PERSON(id, name) VALUES('123', 'Name123');
INSERT INTO PERSON(id, name) VALUES('123', 'Name456');

results single record with name equals to 'Name123', instead of 'Name456' as
I need

I know that I can re write the query but I think that there is a way to do
it via Ignite/Table configuration, am I wrong?

any suggestion would be appreciated. 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: INSERT query that UPDATES if record already found

Posted by vkulichenko <va...@gmail.com>.
Sounds like you're looking for the MERGE command:
https://apacheignite-sql.readme.io/docs/merge

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/