# Update sql table since Power Table

**URL:** <https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493>\
**Category:** Ignition\
**Created:** [May 6, 2020, 6:02pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493 "2020-05-06T18:02:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [May 6, 2020, 6:02pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/1 "2020-05-06T18:02:25Z")

</div>

Hi i tried to update a sql table since a power table i took the code from this url

[https://docs.inductiveautomation.com/display/DOC80/Updating+the+Database+through+the+Power+Table#UpdatingtheDatabasethroughthePowerTable-UsingaPowerTableComponent](https://docs.inductiveautomation.com/display/DOC80/Updating+the+Database+through+the+Power+Table#UpdatingtheDatabasethroughthePowerTable-UsingaPowerTableComponent)

but when i try to make a test the table don´t change anything and the value returns to the original value, don´t sends an error.

I checked the client permission and is Read/write.

can you help me?

thanks

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [May 6, 2020, 9:31pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/2 "2020-05-06T21:31:34Z")

</div>

![error](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/22c6606157ce501ef865757adac5795cd3d4abb6.jpeg)

find the problem, someone knows how to solve this?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2020, 11:32am UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/3 "2020-05-07T11:32:16Z")

</div>

It would be helpful if you showed us your code, but at a guess, you are trying to use _event_, where no event exists.

If you look at the example at the link you posted, you will see they use _self_.

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [May 7, 2020, 12:50pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/4 "2020-05-07T12:50:08Z")

</div>

Hi Jordan

With selft is the same error “NameError: name ‘self’ is not defined”

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2020, 12:56pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/5 "2020-05-07T12:56:19Z")

</div>

.

> [@JordanCClark](#):
>
> It would be helpful if you showed us your code

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [May 7, 2020, 1:19pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/6 "2020-05-07T13:19:42Z")

</div>

![Captura](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/216ac74a4875d62be99c838cec86f8ff3f4baf7b.jpeg)

Here the code

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2020, 1:42pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/7 "2020-05-07T13:42:26Z")

</div>

Hi Eric,

The indentation needs to match the rest of the function. Put a tab space in front of your lines to match the tab spacing above it.

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [May 7, 2020, 5:06pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/8 "2020-05-07T17:06:34Z")

</div>

Hi

i puted the indentation and woorks the first two lines but now i have other error

 ![Captura](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/54a256082d6055bdf5a214528962e807827df0eb.jpeg)

move the identation, checked the query and other things and the same error

thanks for your help.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2020, 5:35pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/9 "2020-05-07T17:35:45Z")

</div>

Hard to tell from the limited error message you posted. Somewhere in there should be a ‘Caused by’ line that may provide a clue.

Is the database on the default connection? If not, you’ll need to specify the correct db connection. It’s a good habit to always specify it anyway, because if you run the function from the gateway, you must tell it the connection. Always specifying it covers all instances.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2020, 5:39pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/10 "2020-05-07T17:39:01Z")

</div>

Also, the Legacy Database Access permission must be enabled.

 ![2020-05-07_13-38-43](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/40c0f82f8248aa34c56adf326ead5949a8d31d16.png)

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [May 7, 2020, 7:28pm UTC](https://forum.inductiveautomation.com/t/update-sql-table-since-power-table/34493/11 "2020-05-07T19:28:47Z")

</div>

Hi Jordan i soved my problem,

in the line needs to put the name of the dataBase

system.db.runPrepUpdate(query, args, ‘your database’)
