Best Programming Practices with servoy

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Best Programming Practices with servoy

Postby ebrandt » Thu Jul 08, 2004 3:20 pm

Currently in my FM solution I have a table called orders. Each order has different status options.

Here is one status field

Estimate_Completion_Status:
'Complete' if Estimate_Completion_Date is valid
'Incomplete' if Estimate_Completion_Date is empty

For my estimate queue, I have a script that:
preforms a find based on the Estimate_Completion_ Status being 'Incomplete', then displaying a list of records.

In servoy I wanted to display this queue in a tab panel showing the number of records.

I know there are a few ways of accomplishing this one being that I create a field called 'Incomplete_Staus' that has the calculated value of 'Incomplete'. Create a self join relationship in the orders table:
Estimate_Completion_Status = Incomplete_Status

This would accomplish what I need. Would there be drawbacks from a self join relationship having to evaluate thousands of records, would this slow anything down?

Or could I accomplish this more efficeintly using a search method of some sort?

Thanks for any input.
Erich
ebrandt
 
Posts: 590
Joined: Tue Mar 30, 2004 6:54 pm
Location: largo, fl

Postby bcusick » Tue Jul 13, 2004 9:15 pm

Hi Erich,

You could do a self-join like you've suggested, or you can do a "find" method that's linked to the "onShow" property of the form. For example:

controller.find()
status = 'Incomplete'
controller.search()

Either way - it will be the same "speed" - as it's all SQL under the hood. I'm not 100% sure, but it seems like doing the straight "find" would be faster, since the SQL database doesn't have to evaluate the join... but again, the difference is negligible.

Hope this helps,

Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby ebrandt » Tue Jul 13, 2004 9:36 pm

Bob,

I have created the on show method attached to my estimate queue form:

controller.find()
order_classification = '%Flexible Endoscope%'
estimate_status = '%Incomplete%'
controller.search(true,false)

I have a controller attached to this form that is a button based menu. I have a button that runs the onshow method:

forms.FlexQCServiceEstimateListing.controller.show()

If I open two clients, on one I keep the estimate queue open,
on the other I receive An item:

controller.newRecord()
var currentState = elements.BtnReceiveService.transparent;
elements.BtnReceiveService.transparent = !currentState;
application.showFormInDialog(forms.ServiceReceivingClassForm,200,200,200,69,'Select Service Class',false,false,true);
controller.saveData()

When I select the Estimate Queue button again to perform the onshow find my new record does not show up until I go to a different screen and back. (Maybe because I am already showing the form?)

What code could I add to my onshow find to refresh my found with the least amount of code?

Hope this was understandable.

Thanks,
Erich
ebrandt
 
Posts: 590
Joined: Tue Mar 30, 2004 6:54 pm
Location: largo, fl

Postby bcusick » Tue Jul 13, 2004 9:50 pm

Erich,

You can use databaseManager.refreshRecordFromDatabase to refresh a record.

From the "Move Sample" code:

//Refresh record from database incase other programs did change the database record
//refresh the second record from current foundset (-1 can be used to refresh all records but is more expensive operation)
databaseManager.refreshRecordFromDatabase(foundset,2)

Hope this helps,

Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby ebrandt » Tue Jul 13, 2004 9:52 pm

Muchas Gracias
ebrandt
 
Posts: 590
Joined: Tue Mar 30, 2004 6:54 pm
Location: largo, fl

Postby ebrandt » Tue Jul 13, 2004 10:07 pm

From what I can see this updates the data in the found set, it does not do a (Refind)

I think I will have to use this one

var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
fsUpdater.setColumn('customer_type',1)
fsUpdater.setColumn('my_flag',0)
fsUpdater.performUpdate()

Thanks
ebrandt
 
Posts: 590
Joined: Tue Mar 30, 2004 6:54 pm
Location: largo, fl


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 32 guests

cron