2016-02-19 54 views
0

EDIT:见底部上的较小的STAT /模式集“值不是记录或记录ID”时传递批次变量设置为“设定=”在更新

I”重现该问题在OrientDB时间序列用例的实验中,我试图链接两棵树的每个级别。所以,我没有这个SQL批处理:

let $w1 = select expand(W1[2406]) from #12:2; 
let $w2 = select expand(W1[2407]) from #12:2; 
let $d1 = select expand(D1[4]) from $w1; 
let $d2 = select expand(D1[0]) from $w2; 
let $h1 = select expand(H1[23]) from $d1; 
let $h2 = select expand(H1[0]) from $d2; 
let $m1 = select expand(M1[59]) from $h1; 
let $m2 = select expand(M1[0]) from $h2; 
update $w1 set next = $w2; 
update $w2 set previous = $w1; 
update $d1 set next = $d2; 
update $d2 set previous = $d1; 
update $h1 set next = $h2; 
update $h2 set previous = $h1; 
update $m1 set next = $m2; 
update $m2 set previous = $m1; 

但我得到的第一个更新此错误:

The field 'W1.next' has been declared as LINK but the value is not a record or a record-id 

...我不明白,因为当我尝试:

return [$w1, $w2, $d1, $d2, $h1, $h2, $m1, $m2]; 

我得到了预期的记录...

所以有两个问题:

  1. 为什么会出现此错误?
  2. 有没有更好的方法来做到这一点,因为我还是一个初学者?

(注:我想留在SQL/SQL批处理)

类是这样的:

Symbol{ 
    W1 : LINKMAP W1 
} 

W1 { 
    next : LINK W1 
    previous : LINK W1 
    D1 : LINKMAP D1 
} 
D1 { 
    next : LINK D2 
    previous : LINK D2 
    H1 : LINKMAP H1 
} 
H1 [...] 
M1 [...] 

编辑:如何重现上一个较小的数据集的问题:

创建模式:

create class A extends V; 
create class B extends V; 
create property A.B LINKMAP B; 
create property B.B LINK B; 

注:AB是状阵列乙元件的,BB是1to1链路

虚设插入值:

insert into B CONTENT {} 
insert into B CONTENT {} 

现在,得到两个假人的RID插入到甲

select from B 

现在插入如下的两个项目(#13:0#13:1在我的情况)

insert into A(B) values ({'0' : #13:0, '1' : #13:1}) 
insert into A(B) values ({'0' : #13:0, '1' : #13:1}) 

最后,尝试此批:

let $b1 = select expand(B[0]) from A; 
let $b2 = select expand(B[1]) from A; 
update $b1 SET B = $b2; 
update $b2 SET B = $b1; 

看到错误

字段“B.B”已被宣布为链接,但该值不是一个记录或记录ID

,但如果你这样做:

let $b1 = select expand(B[0]) from A; 
let $b2 = select expand(B[1]) from A; 
return $b1; 

let $b1 = select expand(B[0]) from A; 
let $b2 = select expand(B[1]) from A; 
return $b2; 

let $b1 = select expand(B[0]) from A; 
let $b2 = select expand(B[1]) from A; 
return {'b1': $b1, 'b2' : $b2}; 

你可以看到它们不是收藏品,但是真实记录

EDIT2由Isavio提供的解决方案的工作,但我想知道为什么它在以前的结果,因为他们似乎并不收集?

let $b1 = select expand(B[0]) from A; 
let $b2 = select expand(B[1]) from A; 
update $b1 SET B = $b2[0]; 
update $b2 SET B = $b1[0]; 
+0

嗨,你有一个简单的数据库测试分享? – LucaS

+0

呃...是的,我想我可以给你一些东西 –

回答

1

可能是更新的结果是记录的集合?你可以尝试使用:

..... 
update $w1 set next = $w2[0]; 
.... 

编辑

我认为使用LET将导致总的集合。

+0

扩大阻止它正常 –

+0

这有效地工作,但我想知道为什么要验证答案;)(我的意思是,为什么然后用'return { 'b1':$ b1,'b2':$ b2};'它不返回一个单独的集合? –

+0

我编辑了答案 – lsavio