INSERT statements and Servoy

Home for older / inactive topics

INSERT statements and Servoy

Postby Jan Aleman » Mon Jul 05, 2004 4:41 pm

Q. Why can't I use INSERT and UPDATE database statements in Servoy?

A. Servoy provides databroadcasting, that means that if two people are looking at the same record and one changes the record the changes will automatically be broadcasted to the other user's screen. Additionally Servoy has caching mechanisms to ease the load on your backend database. If Servoy would allow inserts insert and update statements to be executed the broadcasting and caching mechanisms are not effective anymore.

To INSERT records make sure to have a form based on the table you want to insert into and use Servoy's functions to insert data:
Code: Select all
controller.newRecord()
columname = 'value'
columname2 = 'value2'
....
controller.saveData()

To UPDATE records make sure you have a form based on the table you want to update the record on. Find the record by using a find or using a loadRecords function. Change the columns you want to change using:
Code: Select all
columname = 'value'
controller.saveData()


--UPDATE
It is possible now to run your own insert statements, Servoy also provides functions to communicate this with the cache. You can either flush all cache if you did a big update/insert.

Code: Select all
var done = plugins.rawSQL.executeSQL("example_data","employees","update employees set country = 'NL'")
if(done)
{
   plugins.rawSQL.flushAllClientsCache("example_data","employees")
}


or you can selectively tell the Servoy cache which rows you have touched.

Code: Select all
plugins.rawSQL.notifyDataChange(servername,tableName,IDataSet pksdataset,number action)
serverName - the specified Servoy named database server connection.
tableName - the specified table in the backend database.
IDataSet pksdataset - the specified table in the backend database.
number action - the specified action.
//pks deleted
var action = 1
//pks inserted
var action = 2
//pks updates
var action = 3

//example

var pksdataset = databaseManager.convertToDataSet(new Array(12,15,16,21));
plugins.rawSQL.notifyDataChange(co'employees',pksdataset,3);
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby stephan » Tue Jul 06, 2004 8:26 am

I try to do this as much as I can but that's not always possible.

For some tasks the only way to go is SQL (which I do using a store procedures) ... but then I have the problem a data actualization between Servoy's cache and the database.

One nice thing would be to be able to selectively disable the cache for a form, for a dataprovider within a form or just for a dataprovider (whatever the form). Probably the last option makes the most sense.
stephan
 
Posts: 76
Joined: Thu Jun 03, 2004 3:30 pm

Re:

Postby Jan Aleman » Sun Aug 10, 2008 7:26 pm

stephan wrote:I try to do this as much as I can but that's not always possible.

For some tasks the only way to go is SQL (which I do using a store procedures) ... but then I have the problem a data actualization between Servoy's cache and the database.

One nice thing would be to be able to selectively disable the cache for a form, for a dataprovider within a form or just for a dataprovider (whatever the form). Probably the last option makes the most sense.


I updated the original post to reflect that it is now possible to run your own updates and deletes.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth


Return to Archive

Who is online

Users browsing this forum: No registered users and 2 guests