以下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列创建值。
答案 0 :(得分:2)
如果您的ID为1的父级和ID为2的子级,则可以使用:
Insert into MyApp.Parent_Children values (1,null,2,'fzj')
将ID为2的子项添加到ID为1的父项的子数组中,并在数组“fzj”中具有键值。