> For the complete documentation index, see [llms.txt](https://help.besmart.software/erpc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.besmart.software/erpc/data-interface-reference-manual/importing-data-into-a-vault/writing-data-into-data-interface/using-sql-stored-procedure/example-2-insert-two-associated-ecentity-records.md).

# Example #2 – insert two associated EcENTITY records

Example #2 – insert two associated EcENTITY records

```sql
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;
```
