문제

The following objectscript will create the following SQL table:

Objectscript Class

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

Parent_Children table and columns:

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

When the Parent is saved in objectscript via the %Save() command and the Parent's children property has an element, a row is automatically created in this join table. The ID column has a value like "15||1", the Parent column has the primary key of the Parent row and the Children column has the primary key of the child row.

In SQL, how do I create an insert statement for this table? I do not know how to make the value for the ID column.

도움이 되었습니까?

해결책

If you have a parent with ID of 1 and child with ID of 2 you could use:

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

which would add a child with ID of 2 to the array of children for the parent with ID of 1, and have a key value in the array of "fzj".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top