# I need to create records via SQL INSERTS

**URL:** <https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046>\
**Category:** Classic Servoy\
**Created:** [June 17, 2004, 9:58am UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046 "2004-06-17T09:58:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![elmono\_acosta](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@elmono\_acosta](https://forum.servoy.com/u/elmono_acosta)\
**Post date:** [June 17, 2004, 9:58am UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/1 "2004-06-17T09:58:21Z")

</div>

Is it possible to setup a string with an sql INSERT command so I can create record in my database this way ?

Some times when you need to create records in a 3 or even 4 way relationship, it is much easier with sql rather than with the standard method with servoy.

If the answare is YES, HOW ???  
Thanks.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 17, 2004, 10:19am UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/2 "2004-06-17T10:19:14Z")

</div>

You could do it by making a stored procedure in your database, to which you pass your insert statement, then the SP evaluates your string and executes it.

But, this insert will not be reflected in Servoy Client/Developer, untill you restart it.

I’m sure some other people on the forum will tell you it’s not so hard to do the same through Servoy ![:D]( "Very Happy")

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [June 17, 2004, 5:12pm UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/3 "2004-06-17T17:12:10Z")

</div>

You **cannot** execute “raw” SQL statements (except for SELECT) in Servoy. The reason is because of client data consistency. If you did a delete or insert of tens or hundreds of records - how would Servoy “know” what records were affected? Answer - it wouldn’t - so you could wind up in a situation where a client was looking at invalid data.

Instead - use a stored procedure to insert records or you can also use a loop in Servoy and add the records that way as well.

Hope this helps,

Bob Cusick

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [June 18, 2004, 3:45pm UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/4 "2004-06-18T15:45:56Z")

</div>

You could use a plugin to do an insert. But, like Bob said, Servoy would not be aware of the changes and could mean chaos.

I’m using a plugin to do a special insert into a table under special circumstances, but this is not recommended if not necessary.

---

<div class="post-metadata">

**Author:** ![elmono\_acosta](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@elmono\_acosta](https://forum.servoy.com/u/elmono_acosta)\
**Post date:** [June 18, 2004, 7:10pm UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/5 "2004-06-18T19:10:46Z")

</div>

OK.  
What about if I use the plug in, and every time servoy wants to read data from the database I use a method that does:

//flushes the client data cache for recordIndex -1  
//in the related foundset  
//-1 for all data

databaseManager.refreshRecordFromDatabase(order\_to\_orderdetails,-1);

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [June 20, 2004, 9:08pm UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/6 "2004-06-20T21:08:02Z")

</div>

I’m not sure. It could work, maybe one of the Servoy kids can help answer that. Never the less, I wouldn’t recommend intense use of this method.

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [June 24, 2004, 12:16pm UTC](https://forum.servoy.com/t/i-need-to-create-records-via-sql-inserts/2046/7 "2004-06-24T12:16:02Z")

</div>

Invaliditing cache can have enormous performance impact, imagine what would happen if you have 1000 users of your solution and you keep invaliditing theire entire cache all the time.

Why don’t you simply create a form on the table you want to insert to and create new records through that? It doesn’t matter at all how many relations away it is, you can address it directly. Aditionally that is also easier to code than INSERT statements and broadcasting and caching remains accurate.
