# inserts and updates via SQL

**URL:** <https://forum.servoy.com/t/inserts-and-updates-via-sql/1012>\
**Category:** Classic Servoy\
**Created:** [January 13, 2004, 10:32pm UTC](https://forum.servoy.com/t/inserts-and-updates-via-sql/1012 "2004-01-13T22:32:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xtsr\_1](https://avatars.discourse-cdn.com/v4/letter/x/ea5d25/32.png) [@xtsr\_1](https://forum.servoy.com/u/xtsr_1)\
**Post date:** [January 13, 2004, 10:32pm UTC](https://forum.servoy.com/t/inserts-and-updates-via-sql/1012/1 "2004-01-13T22:32:49Z")

</div>

How can I do “inserts into” and “updates” on a table using SQL queries? I tried “getDataSetByQuery”, which didn’t work (could be another reason, but judging from the name wouldn’t surprise me if it wasn’t supposed to work).

BTW, I’m using MySQL on OS X as db.

I’m new to Servoy, so please forgive me if this is a beginner’s question, but i couldn’t find an answer in the forum or in help…

Thanks!  
Reto

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [January 14, 2004, 12:00am UTC](https://forum.servoy.com/t/inserts-and-updates-via-sql/1012/2 "2004-01-14T00:00:27Z")

</div>

If you edit records, Servoy will make the insert/updates for you, we do not allow SQL update/inserts because it breaks the data notification between clients.  
(Servoy must be aware of all database changes, if update is done directly on database outside Servoy you must flush the client caches via the admin page)

---

<div class="post-metadata">

**Author:** ![youseful](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@youseful](https://forum.servoy.com/u/youseful)\
**Post date:** [January 20, 2004, 8:41pm UTC](https://forum.servoy.com/t/inserts-and-updates-via-sql/1012/3 "2004-01-20T20:41:04Z")

</div>

Here in pseudo code

Do\_SQL\_Insert();  
Notify\_Server();

In Notify\_Server() you notify the server that clients must flush cache.  
On the client side there a Cache\_flush event that can be Triggered.

What kind of perfermance hit would this be?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [January 21, 2004, 9:41am UTC](https://forum.servoy.com/t/inserts-and-updates-via-sql/1012/4 "2004-01-21T09:41:46Z")

</div>

yes but what to flush?  
Everything over ALL the clients??

that would be a huge drain…

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [February 5, 2004, 12:27pm UTC](https://forum.servoy.com/t/inserts-and-updates-via-sql/1012/5 "2004-02-05T12:27:27Z")

</div>

Servoy 2.0 rc5 will support updates like this:

```auto
//1) update entire foundset
var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
fsUpdater.setColumn('customer_type',1)
fsUpdater.setColumn('my_flag',0)
fsUpdater.performUpdate()

```

So when your foundset is as big as the entire table, the entire table will be updated

```auto
//2) update part of foundset, for example the first 4 row (starts with selected row)
var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
fsUpdater.setColumn('customer_type',new Array(1,2,3,4))
fsUpdater.setColumn('my_flag',new Array(1,0,1,0))
fsUpdater.performUpdate()

```

And will notify the other clients about the update.
