Page 1 of 1

Best Programming Practices with servoy

PostPosted: Thu Jul 08, 2004 3:20 pm
by ebrandt
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

PostPosted: Tue Jul 13, 2004 9:15 pm
by bcusick
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

PostPosted: Tue Jul 13, 2004 9:36 pm
by ebrandt
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

PostPosted: Tue Jul 13, 2004 9:50 pm
by bcusick
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

PostPosted: Tue Jul 13, 2004 9:52 pm
by ebrandt
Muchas Gracias

PostPosted: Tue Jul 13, 2004 10:07 pm
by ebrandt
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