# Return the block\_id from transaction group after execution

**URL:** <https://forum.inductiveautomation.com/t/return-the-block-id-from-transaction-group-after-execution/26212>\
**Category:** Ignition\
**Created:** [July 2, 2019, 3:02am UTC](https://forum.inductiveautomation.com/t/return-the-block-id-from-transaction-group-after-execution/26212 "2019-07-02T03:02:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [July 2, 2019, 3:02am UTC](https://forum.inductiveautomation.com/t/return-the-block-id-from-transaction-group-after-execution/26212/1 "2019-07-02T03:02:35Z")

</div>

I would like to set up some relational tables , and preferably use Ignitions transaction groups to do so.  
But i’m running into a bit of a problem with the conceptual idea.  
I would like to insert a row into a table that represents a production item. I would like to be able to use the auto incrementing column of the table as a unique ID for this item, which i can then use in other transaction groups that may provide relational data.  
I don’t see a way to extract this though.  
I will need this value to be used in a PLC which is compiling the relational data.

Is the only option to use an SQL query tag which reads the MAX(block\_id) out? How could i write that to the PLC though?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 2, 2019, 12:16pm UTC](https://forum.inductiveautomation.com/t/return-the-block-id-from-transaction-group-after-execution/26212/2 "2019-07-02T12:16:32Z")

</div>

I would use a stored procedure group. Have your stored procedure return the new ID as an OUT parameter.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [July 2, 2019, 9:26pm UTC](https://forum.inductiveautomation.com/t/return-the-block-id-from-transaction-group-after-execution/26212/3 "2019-07-02T21:26:01Z")

</div>

Thanks Phill I’ll look into using a stored procedure.

I’ve acually got a slightly different use case pop up which i’m not sure i can achieve with a stored procedure.

I have a Block Transaction group which writes a block of data to SQL on a trigger. There are 500 rows, 3 columns. Each trigger is inserting a new block and hence generating a new block\_id.  
I would like to get this new block\_id into the PLC somehow.

It doesn’t look like Stored Procedure groups support block inserts though.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [July 2, 2019, 9:30pm UTC](https://forum.inductiveautomation.com/t/return-the-block-id-from-transaction-group-after-execution/26212/4 "2019-07-02T21:30:36Z")

</div>

At this stage i’m thinking of having two tags to achieve this.  
SQL tag to read MAX(block\_id) from table.  
OPC tag to write to PLC.

Add an on-change script to the SQL tag, if value changes, write it to the OPC tag.  
Then the PLC can detect the new block\_id and act appropriately.
