InterSystems缓存 - 如何插入连接表?

时间:2013-08-01 17:47:09

标签: sql intersystems-cache objectscript

以下objectscript将创建以下SQL表:

Objectscript类

Class MyApp.Parent Extends %Persistent
{
Property Children As array Of MyApp.Child;
}

Parent_Children表和列:

Parent int NOT NULL,
ID varchar(254) NOT NULL,
Children int NULL,
element_key varchar(50) NOT NULL

当通过%Save()命令将Parent保存在objectscript中并且Parent的children属性具有元素时,将在此连接表中自动创建一行。 ID列的值类似"15||1",Parent列的主键为Parent行,Children列的主键为{{1}}行行。

在SQL中,如何为此表创建insert语句?我不知道如何为ID列创建值。

1 个答案:

答案 0 :(得分:2)

如果您的ID为1的父级和ID为2的子级,则可以使用:

Insert into MyApp.Parent_Children values (1,null,2,'fzj')

将ID为2的子项添加到ID为1的父项的子数组中,并在数组“fzj”中具有键值。