# Writing back to a database

**URL:** <https://forum.inductiveautomation.com/t/writing-back-to-a-database/59359>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 9, 2022, 2:27pm UTC](https://forum.inductiveautomation.com/t/writing-back-to-a-database/59359 "2022-05-09T14:27:57Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 10, 2022, 2:42pm UTC](https://forum.inductiveautomation.com/t/writing-back-to-a-database/59359/8 "2022-05-10T14:42:55Z")

</div>

> [@mjohnson0238](#):
>
> and works like it should. I suppose I am having a hard time understanding the script differences in vision vs perspective.

The biggest difference is that scripts in perspective run in a `Gateway` scope.

When you run some functions like `system.db.runPrepUpdate` in `Gateway` scope you will need to provide additional information. In this instance what database connection to run the query against.

When running in a vision client, if you don't provide the database connection, then the default connection is assumed. Thus the script works in a vision client, but not in perspective.

See the syntax section on this page in the manual:  
[https://docs.inductiveautomation.com/display/DOC81/system.db.runPrepUpdate](https://docs.inductiveautomation.com/display/DOC81/system.db.runPrepUpdate)

Notice how in the Gateway scope the `database` parameter is required and how in vision client scope the `database` parameter is optional (denoted by the `[]` surrounding it?

I will give you that it is a bit confusing that it also state that syntax will work in `perspective session` scope, in my experience it's best to assume that code will be running in the Gateway.

Get in the habit of always providing the database and you wont run into this particular problem.

---

_[View the full topic](https://forum.inductiveautomation.com/t/writing-back-to-a-database/59359)._
