Was there a resolution on this ? There is UPSERT in Orientdb but it doesnt exactly solve this use case What i am looking for is
UPDATE INTO Table1 (a,b,c) from (select a,b,c from Table2) If a,b,c exists then replace it. On Wednesday, January 15, 2014 7:37:36 AM UTC-8, Giraldo Rosales wrote: > > Sure. Basically would need to combine an INSERT and UPDATE. If the > document exists, UPDATE it. If it does not exist, create (or INSERT) it. > > In the following example, If a document exists with a class, Users, has a > property, "id", of "1", then update the "name". If it does not, create the > document with class, Users, with the properties, id="1" and > name="something". > *REPLACE FROM Users SET **name="something"** WHERE id="1"* > > In the following example, If a document exists with a class, Users, has a > property, "id", of "1" AND "type" is "5", then update the "name". If it > does not, create the document with class, Users, with the properties, > id="1", type=5, and name="something". If a document has id=1 but type=4, a > new document would still be created since the type would not match. > *REPLACE FROM Users SET **name="something"** WHERE id="1" AND type="5"* > > The keyword could be REPLACE or MERGE. Neo4j uses MERGE, MySQL uses > REPLACE. It helps because it avoids having to do a SELECT request to see if > a document exists, then have a conditional to either update or insert it. > > *To explain in more detail, here are some examples from MySQL and Neo4j:* > http://dev.mysql.com/doc/refman/5.7/en/replace.html > http://docs.neo4j.org/chunked/milestone/query-merge.html > > Thanks Andrey! > > > On Wednesday, January 15, 2014 10:19:23 AM UTC-5, Andrey Lomakin wrote: >> >> Hi Giraldo, >> No we do not have REPLACE functionality now. >> Could you explain in details what do you expect from this functionality >> so we will or implement it or provide alternative solution. >> >> >> On Tue, Jan 14, 2014 at 7:37 PM, Giraldo Rosales <[email protected]> >> wrote: >> >>> Was curious as to if there is a REPLACE function like in MySQL or a >>> MERGE like in Neo4j? I had just wanted to perform an INSERT but if an index >>> existed, update it. Or the other way around. Perform an UPDATE with a WHERE >>> and if a document was not found, insert. >>> >>> Saw the following: >>> >>> https://groups.google.com/forum/#!searchin/orient-database/update$20insert$20if$20exist/orient-database/ExUYAgcm5Rg/5OHUv6ud82IJ >>> >>> Does this mean that REPLACE does not exist and does not have any >>> intention on being added? We would have to create a custom function? >>> >>> Thanks! >>> >>> -- >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "OrientDB" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> Best regards, >> Andrey Lomakin. >> >> Orient Technologies >> the Company behind OrientDB >> >> -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
