# Writing Variable Number Of Rows to PLC Array

**URL:** <https://forum.inductiveautomation.com/t/writing-variable-number-of-rows-to-plc-array/32637>\
**Category:** Ignition\
**Created:** [February 26, 2020, 4:47pm UTC](https://forum.inductiveautomation.com/t/writing-variable-number-of-rows-to-plc-array/32637 "2020-02-26T16:47:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruzzolino](https://avatars.discourse-cdn.com/v4/letter/r/e0b2c6/32.png) [@ruzzolino](https://forum.inductiveautomation.com/u/ruzzolino)\
**Post date:** [February 26, 2020, 4:47pm UTC](https://forum.inductiveautomation.com/t/writing-variable-number-of-rows-to-plc-array/32637/1 "2020-02-26T16:47:59Z")

</div>

I am trying to use a block group to write a variable number of rows from a SQL database to my PLC array using the SQL Bridge Module. The problem is that if the results is less than the last query, then it will fill the array with the new data and entries from the old data. Is there a way to clear the block data after it writes to the PLC?

---

<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:** [February 26, 2020, 4:57pm UTC](https://forum.inductiveautomation.com/t/writing-variable-number-of-rows-to-plc-array/32637/2 "2020-02-26T16:57:21Z")

</div>

Sounds like a job for a script instead of a block group.

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [February 26, 2020, 5:58pm UTC](https://forum.inductiveautomation.com/t/writing-variable-number-of-rows-to-plc-array/32637/3 "2020-02-26T17:58:34Z")

</div>

It’s a bug, I have a support ticket for it as well.

---

<div class="post-metadata">

**Author:** ![ruzzolino](https://avatars.discourse-cdn.com/v4/letter/r/e0b2c6/32.png) [@ruzzolino](https://forum.inductiveautomation.com/u/ruzzolino)\
**Post date:** [February 26, 2020, 9:26pm UTC](https://forum.inductiveautomation.com/t/writing-variable-number-of-rows-to-plc-array/32637/4 "2020-02-26T21:26:42Z")

</div>

I got it to work by first triggering a stored procedure using using a standard group and a triggered expression item. The stored procedure writes to another table that fills in blank entries. Then triggering the block group to pull the data from that table to the PLC array. A bit of an annoying work around, but it works.
