Hi ,
from the subquery you get a result set not an integer, so you should
extract the value.
For example
> create class LeadMeta
> create property LeadMeta.creator string
> create property LeadMeta.leadCampaign string
> create property LeadMeta.category string
> create property LeadMeta.owner string
> create property LeadMeta.ownerId integer
> create class Sample
> create property Sample.meta EMBEDDEDLIST LeadMeta
> create property Sample.id integer
> insert into Sample set id = 1 , meta =
[{"creator":"a","leadCampaign":"b","category":"c", "owner":"d","ownerId":1}]
For example in _studio table there is a metadata integer @version with
value 1 , so I can run a query similar to yoru subquery, with result 1
> select @version from _studio where @rid = #25:0
Now I can run
> select from #45:0 let $i = ( select @version from _studio where @rid =
#25:0 ) where id = $i[0].version
> select from #45:0 let $i = ( select @version from _studio where @rid =
#25:0 ) where meta.ownerId = $i[0].version
Using 2.2.14 I cannot run "update .. set ...let..".
You can use a script to run the subquery first, and store the integer, the
run update.
Il giorno giovedì 29 dicembre 2016 03:01:17 UTC+1, Borov ha scritto:
>
>
> Hi, I'm trying to run a simple update with a sub-select query, but it is
> just not taking the value from the sub query. I found few examples on
> google, but for some reason mine still not working no matter what I try.
> Here is my query:
>
> orientdb {db=Customers}> update #69:0 set meta.ownerId = (select id from
> Account where @rid = #25:1) Updated record(s) '1' in
> 0.003000 sec(s).
>
> orientdb {db=Customers}> select meta from #69:0
>
>
> +----+-----------------------------------------------------------------------------------+
> |# |meta
> |
>
> +----+-----------------------------------------------------------------------------------+
> |0 |LeadMeta{creator:
> #25:0,leadCampaign:#149:0,category:#45:1,owner:#25:1,ownerId:null}|
>
> +----+-----------------------------------------------------------------------------------+
>
> As you can see it sets "ownerId" to null. I tried get id as id[0] but
> didn't help. The meta.ownerId and the id are both Integers. The sub-query
> on its own is returning the id just fine:
>
> orientdb {db=Customers}> select id from Account where @rid = #25:1
>
> +----+----+
> |# |id |
> +----+----+
> |0 |21 |
> +----+----+
>
> Even when I tried with the hard coded id in the sub-query, it still
> results in null:
>
> orientdb {db=Customers}> update #69:0 set meta.ownerId = (select 21 from
> Account where @rid = #25:1)
> Updated record(s) '1' in 0.002000 sec(s).
>
> orientdb {db=Customers}> select meta from #69:0
>
>
> +----+-----------------------------------------------------------------------------------+
> |# |meta
> |
>
> +----+-----------------------------------------------------------------------------------+
> |0 |LeadMeta{creator:
> #25:0,leadCampaign:#149:0,category:#45:1,owner:#25:1,ownerId:null}|
>
> +----+-----------------------------------------------------------------------------------+
>
> I'm sure I'm doing something wrong, since this is a very trivial
> operation. Just can't see what.
>
>
>
--
---
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.