gpt4 book ai didi

orientdb - 在 orientDB 中编写子查询

转载 作者:行者123 更新时间:2023-12-04 15:39:37 27 4
gpt4 key购买 nike

这是我现在使用的查询:

INSERT INTO details SET name = "INITIALIZE",actionMap ={"1":12:1,"2":12:2};

这里 12:1,12:2 是从另一个表中删除的。我在对这些rid 值进行硬编码时遇到了很多问题。为了避免这种情况,我想添加这样的查询
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 field 'details.actionMap' has been declared as LINKMAP but the value is not a record or a record-id



那么我如何更改我的查询以帮助我的案例。

最佳答案

这确实可以使用批处理以更优雅的方式完成。

这只是为了创建你想要的对象

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 )

如果您对此有任何疑问,请随时提出。

关于orientdb - 在 orientDB 中编写子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49687052/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com