"value is not a record or a record-id" 在更新中将批处理变量传递给 "set ="
"value is not a record or a record-id" when passing batch variable to "set =" in update
编辑:请参阅底部以在较小的 stat/schema 集
上重现问题
我正在围绕 OrientDB time-series 用例进行试验,我正在尝试链接两棵树的每个级别。所以我做了这个 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];
我得到了预期的记录...
所以两个问题:
- 为什么会出现这个错误?
- 我还是初学者,有更好的方法吗?
(注:我想留在sql/batch 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;
注:A.B是一个array-like的B元素,B.B是一个1to1的link
要插入的虚拟值:
insert into B CONTENT {}
insert into B CONTENT {}
现在,去掉两个假人插入A
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' 已声明为 LINK 但该值不是记录或 record-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};
可以看出不是collection,而是真的记录
EDIT2 Isavio 提供的解决方案有效,但我想知道它为什么有效,因为在以前的结果中,它们似乎不是 collection?
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];
莫非更新的结果是一个记录集合?您可以尝试使用:
.....
update $w1 set next = $w2[0];
....
编辑
我认为使用 LET 总是会产生一个集合。
编辑:请参阅底部以在较小的 stat/schema 集
上重现问题我正在围绕 OrientDB time-series 用例进行试验,我正在尝试链接两棵树的每个级别。所以我做了这个 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];
我得到了预期的记录...
所以两个问题:
- 为什么会出现这个错误?
- 我还是初学者,有更好的方法吗?
(注:我想留在sql/batch 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;
注:A.B是一个array-like的B元素,B.B是一个1to1的link
要插入的虚拟值:
insert into B CONTENT {}
insert into B CONTENT {}
现在,去掉两个假人插入A
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' 已声明为 LINK 但该值不是记录或 record-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};
可以看出不是collection,而是真的记录
EDIT2 Isavio 提供的解决方案有效,但我想知道它为什么有效,因为在以前的结果中,它们似乎不是 collection?
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];
莫非更新的结果是一个记录集合?您可以尝试使用:
.....
update $w1 set next = $w2[0];
....
编辑
我认为使用 LET 总是会产生一个集合。