Search code examples
orientdb

Orientdb - extract rid from let variable


This is an excerpt of a bigger query:

BEGIN
 let $project = SELECT FROM Project where id=:projectId
 let $counter = update Project INCREMENT seq=1 RETURN AFTER $current.seq where @rid=project[0].rid
COMMIT
return $project[0]

I am trying to use $project variable to update Project. I guess the best way to do this would be to extract @rid from this variable.

The thing that not works in above query is @rid=project[0].rid

I've tried other options like: @rid=project[0].@rid, @rid=project.rid[0], @rid=project[0]

What is the proper way to do this?


Solution

  • Try selecting immediately the @rid:

    BEGIN
     let $project = SELECT @rid FROM Project where id=:projectId
     let $counter = update Project INCREMENT seq=1 RETURN AFTER $current.seq where @rid=project[0].rid
    COMMIT
    return $project[0]
    

    Hope it helps,

    Regards