Example #2 – insert two associated EcENTITY records

Example #2 – insert two associated EcENTITY records

DECLARE @BulkID int, @EntName nvarchar(100), @EntClassID nvarchar(10)
DECLARE @CldId bigint, @ParId bigint;
SET @BulkID = NULL;
SET @EntName = 'PurchItem 123';
EXEC @CldId = EcWriteEntity @EntName, @BulkID OUTPUT
UPDATE EcENTITY SET category = N'Purchased' WHERE id = @CldId;
SET @EntClassID = 'CUSTENT';
SET @EntName = 'PurchRequest';
EXEC @ParId = EcWriteEntity @EntName, @BulkID OUTPUT, @EntClassID
UPDATE EcENTITY SET
guid = '25737496-b00d-4f2f-a898-2c7df05250d6',
lfcycst_name = N'Approved'
WHERE id = @ParId;
INSERT INTO EcASSOC
(ent_id_parent, ent_id_child, assoc_type)
VALUES
(@ParId, @CldId, 30);
UPDATE EcENTITY SET comm_status = 0 WHERE bulk_id = @BulkID;
SELECT @BulkID;