How to update a foundset (1 of more columns) most efficient?

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How to update a foundset (1 of more columns) most efficient?

Postby mboegem » Fri Dec 12, 2008 4:17 pm

Can anyone tell me the most efficient way to update a foundset for 1 or more columns?

With a fixed value this is easy and fast via databaseManager foundsetupdater.

What I have here is:
2 tables, connected to eachother via primary & foreign key
'foreigntable' has: column X
and I need to get the related value as fast as possible into a large foundset in the 'primarytable'

I could do this by iterating the foundset on a form, but this will be slow.

Is there any way to do this via the foundsetupdater as well, or to push a dataset back to the table (matching key of course)?

Maybe I just overlook possibilities, but I can't get it clear at the moment...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: How to update a foundset (1 of more columns) most efficient?

Postby agiletortoise » Fri Dec 12, 2008 4:42 pm

I'm not sure what your criteria are...but I suspect you could use several passes with foundsetupdater base on different queries rather than looping over the foundset.

g.
Greg Pierce
Agile Tortoise
SAN Developer
http://www.agiletortoise.com
User avatar
agiletortoise
 
Posts: 278
Joined: Wed Oct 12, 2005 3:26 pm
Location: Texas, USA

Re: How to update a foundset (1 of more columns) most efficient?

Postby ROCLASI » Fri Dec 12, 2008 4:43 pm

Hi Marc,

Maybe something like this ? Let the database server do all the work for you:
Code: Select all
var sQuery = "UPDATE myParentTable a SET a.myParentColumn = (SELECT b.myChildColumn FROM myChildTable b WHERE b.parentIdColumn=a.myParentColumn)";
if ( plugins.rawSQL.executeSQL("myServer","myParentTable", sQuery) ) {
   // make sure all clients see the changed data.
   plugins.rawSQL.flushAllClientsCache("myServer", "myParentTable");
} else {
   // an error occured
}


Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: How to update a foundset (1 of more columns) most efficient?

Postby mboegem » Sat Dec 13, 2008 3:23 pm

Thnkx Robert, I guess this can help me.

I was hoping for a possibility with Servoy commands, but this will do the job...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to How To

Who is online

Users browsing this forum: No registered users and 12 guests