The best solution when you have a lot of records on the server is to setup the VirtualTable to select either only one or no records then query them in the parentdatachanged delegate.
Code:
// MSSQL
create virtualtable myorders connstr 'my_dsn' alias myorders as select top(1) * from orders
// MySQL
create virtualtable myorders connstr 'my_dsn' alias myorders as select * from orders limit 1
// LianjaSQL (optimizer does the work and just retrieves table metadata)
create virtualtable myorders connstr 'my_dsn' alias myorders as select * from orders where 1=0
// or alternatively (which is more database independent and faster)
create virtualtable myorders connstr 'my_dsn' alias myorders as select * from orders where 1=0
Now when you actually want to fetch related data you can just do this in the parentdatachanged delegate:
Code:
select myorders
ca = cursorAdaptor()
// Tell the CA what we want to retrieve
ca.selectCmd = "select * from orders where custid={customers.id}
// refresh the data from the server
ca.refresh()
// now update our UI grid section from the local cursor
Lianja.getElementByID("mygrid").refresh()
End result == less network traffic which we all like (and so do our users as the App is faster).
Now worth noting in RC5.3 (already released)
Code:
create virtualtable myorders connstr 'my_dsn' alias myorders properties 'autosync=1" as select top(1) * from orders
Will keep the local and remote cursor data "in sync" as changes are made multi-user.
Bookmarks