Reputation: 51
I am evaluating OrientDB database.
I have two document classes imported from a relational database.
class Order with properties (ID: integer, OrderItems: EmbeddedList of OrderItem)
and
class OrderItem with properties (ID: integer, OrderID: integer, PropA: string)
Both classes are filled with data from the database (except field Order.OrderItems).
Now I would like to insert data from class OrderItem into class Order based on OrderID.
I have tried SQL like
update Order set OrderItems = (select from OrderItem where OrderID = Order.ID)
without success, with error like
The field 'Order.OrderItems' has been declared as EMBEDDEDLIST but the value is document with the valid RecordId ...
I do understand that embedded record should not have RecordId so I have tried
update Order set OrderItems = (select PropA from OrderItem where OrderID = Order.ID)
without success, with error like
The field 'Order.OrderItems' has been declared as EMBEDDEDLIST with linked class 'OrderItem' but the record has no class ...
I have also tried
update Order
set OrderItems = (select @class, PropA from OrderItem where OrderID = Order.ID)
without success.
Is there any other way (OrientDB 2.1.4) ...
Ales
Upvotes: 3
Views: 714
Reputation: 51
I have found the solution
update Order
set OrderItems = (select $current.exclude('@rid') from OrderItem where $parent.$current.ID = OrderID)
Upvotes: 2