eric
eric

Reputation: 533

OrientDB: How to use MATCH in an UPDATE operation?

Is it possible to use MATCH in an UPDATE operation? I've tried things like this:

UPDATE (MATCH...RETURN...) SET...

I assumed it would work, since this does:

UPDATE #12:34 SET...

But I've not been successful with any syntax I could come up with.

So if this is supported, what is the correct syntax to use?

Upvotes: 1

Views: 157

Answers (2)

shanshan xu
shanshan xu

Reputation: 11

it works well

UPDATE EDGE Custom_Family_Of_Custom 
SET survey_status = 'value_1'
WHERE @rid in (
SELECT level1_e.@rid FROM (
MATCH {class: Custom, as: custom, where: (custom_uuid = 'param_uuid_1')}
.bothE('Custom_Family_Of_Custom') {as: e} 
.bothV('Custom') {as: v, where: (custom_uuid = 'param_uuid_2')} 
return e
)
)

Upvotes: 1

Luigi Dell'Aquila
Luigi Dell'Aquila

Reputation: 2814

Yes, you can do it, but the MATCH has to return persistent records, eg.

RETURN $elements

or (in v 3.0)

RETURN expand(x)

If you are using v 3.0, please consider that you just gave me a chance to find a bug (thank you!), so you will have a NullPointerException on the RC2. I already fixed it, the fix will be in the snapshot in a few minutes and will be released with the first 3.0.0 GA

Upvotes: 1

Related Questions