这是我现在正在使用的查询:
INSERT INTO details SET name = "INITIALIZE",actionMap ={"1":12:1,"2":12:2};
这里12:1,12:2摆脱了另一张桌子。我面临很多问题,硬编码这些摆脱的价值。为了避免这种情况,我不知道这个问题。喜欢像这样添加查询
INSERT INTO details SET name = "INITIALIZE",actionMap ={"1":(select @rid from action where start is not null),"2":(select @rid from action where stop is not null)};
我得到了这个例外:
com.orientechnologies.orient.core.exception.OValidationException:The 字段&detail; action.actionMap'已被宣布为LINKMAP但是 value不是记录或记录ID
那么如何更改我的查询以帮助我的案例。
答案 0 :(得分:1)
这确实可以使用批次以更优雅的方式完成。
这只是为了创建你想要的对象
INSERT INTO details SET name = "INITIALIZE"
我们将把它变成
let $inserted = INSERT INTO details SET name = "INITIALIZE"
添加您想要添加的边缘:
CREATE EDGE actionMap FROM $inserted TO (SELECT FROM action WHERE start is not null )
CREATE EDGE actionMap FROM $inserted TO (SELECT FROM action WHERE stop is not null )
所以你必须运行的整个批次是
let $inserted = INSERT INTO details SET name = "INITIALIZE"
CREATE EDGE actionMap FROM $inserted TO (SELECT FROM action WHERE start is not null )
CREATE EDGE actionMap FROM $inserted TO (SELECT FROM action WHERE stop is not null )
如果您对此有任何疑问,请随时提出。
答案 1 :(得分:0)
let $a1 = SELECT FROM action WHERE start IS NOT null
let $a2 = SELECT FROM action WHERE stop IS NOT null
INSERT INTO details SET name = "INITIALIZE", actionMap = {"1": $a1[0], "2": $a2[0]}
这是原始答案,适用于LINKLIST
您的错误说明:
字段&detail; action.actionMap'已被声明为LINKMAP,但该值不是记录或记录ID
您正在尝试将值存储到应该存储引用的字段中
根据orientDB docs
您存储如下参考:
INSERT INTO Profiles SET name = 'Luca', friends = [#10:3, #10:4]
或SELECT
子查询:
INSERT INTO Diver SET name = 'Luca', buddy = (SELECT FROM Diver
WHERE name = 'Marko')
这将使您的代码成为:
INSERT INTO details SET name = "INITIALIZE", actionMap =[(SELECT FROM action WHERE start IS NOT null),(SELECT FROM action WHERE stop IS NOT null)];
额外提示:
如果您同时对您的操作进行操作,那么您可以使用一个查询添加details
和那些action
:
INSERT INTO details SET name = "INITIALIZE", actionMap = [(INSERT INTO yourActionTable SET yourActionField = 'yourFirstAction'), (INSERT INTO yourActionTable SET yourActionField = 'YourSecondAction')]