Principal developer of Lianja, Recital and other products
Follow me on:
Twitter: http://twitter.com/lianjaInc
Facebook: http://www.facebook.com/LianjaInc
LinkedIn: http://www.linkedin.com/in/barrymavin
Working through a similar scenario, created a database as an import from MySQL. Create a VT to my MySQL instance.
Create a grid based on the VT table.
Now I try to confirm that an update of MySQL table can be reflected in the lianja app based on the info here.
(running this at the console...numbering on left only indicates the order in which these are run)
1). ca=cursorAdaptor("vtdata") //vtdata is my vt alias name
2). ca.requery("select * from vtdata;") //this I believe is right SQL to use
//(see below actual SQL code when I built the VT marked by :0001)
3). mm = Lianja.getElementByID("secGRID").grid
4). mm.clear() //tried skipping this as well but no joy.
5). mm.refresh()
also tried the following in place of 3,4,5
Lianja.getElementByID("secGRID").refresh()
ref: 0001 SELECT A.ACTOR_ID, B.FILM_ID, C.TITLE FROM actor A, film_actor B, film C where A.ACTOR_ID = B.ACTOR_ID AND B.FILM_ID = C.FILM_ID;
At the console, I can run the sql "select * from vtdata" and this does show the data as a live representation from MySQL.
However the routine to update the grid only upates the heading only and no data.
The SQL at the command/console takes about "5462 records selected in 10ms".
P.S, looking at this with djtropez
In fact what you are doing is wrong. Let me clarify.
1. requery( "where_condition" ) e.g.
When orders is used in a grid you will see no records as the "where 1=0" is specified.Code:CREATE VIRTUALTABLE cox CONNSTR 'whatever' AS select * from orders where 1=0
requery() will requery the ODBC data source with a new where condition. e.g.
So... If you use that in a parentDataChanged delegate on the grid section like this. (assuming customers is the parent and orders coming from MySQL is the child):Code:ca.requery("customer='smith'")
2. If all you want to do refresh the grid with the exact same SQL query just do this.Code:proc page1_section1_parentDataChanged() ca=cursorAdaptor("vtdata") ca.requery("customerid='{customers.id}'") // note the use of { } to build the query before it is executed in MySQL Lianja.getElementByID("secGRID").refresh() endproc
Using ca.requery("select * from vtdata;") is incorrect. Also you don't need to select * from vtdata, that is performing 2 SQL queries, one on the server and one on the client. You should only do that when you want to join disparate data sources e.g. Lianja table to a MySQL table.Code:ca.cursorRefresh() Lianja.getElementByID("secGRID").refresh()
Note:
You have two things at play here, the data source which is queried into the local cursor, and the grid which is the "view" on that data.
What Lianja does is provide a visual representation in the UI of what you think of in terms of "How is my data related together" and how do I visualize it in my mind e.g.
(one) customers --> (many) orders --> (many) orderDetails
I hope that helps to clarify how to use Virtual Tables.
Last edited by barrymavin; 2013-09-11 at 20:52.
Principal developer of Lianja, Recital and other products
Follow me on:
Twitter: http://twitter.com/lianjaInc
Facebook: http://www.facebook.com/LianjaInc
LinkedIn: http://www.linkedin.com/in/barrymavin
Principal developer of Lianja, Recital and other products
Follow me on:
Twitter: http://twitter.com/lianjaInc
Facebook: http://www.facebook.com/LianjaInc
LinkedIn: http://www.linkedin.com/in/barrymavin
I am using RC8 and suggestions and pointers given assisted in understanding.
However, please see the following image, have two comments to make
1). Not sure if this is just a version issue, but my vt tables are not reported correctly when I am in the app/page view.
and in database/data view, where they are reported as only tables. Only one is indicated as vt
dir command however reports all expected resources ok.
2). When you open a section based on the tables, either standard table or vt. The table indicated in uppercase, this can be a bit confusing.
I can reproduce the hover display behaviour with a virtual table that has no records, but not ones with records. Was there anything different in the way these were created as opposed to vtdata? Do they still show as 'Tables' if you reopen the database or App?
Regards,
Yvonne
Been tying myself in knots with this, and what I have come up with is first, create app, connect to the database, and while the app and database are in 'connected' mode, go and add the vt's. Now the twist is that in the resultant vt's sql statement, there are around 5462 records, and on each occassion, creating a vt with same sql statement, the total number of records returned (shown in brackets) is different. I am working on a local machine for the database as well and on a fairly decent machine but can't understand this. Will try it all on a different machine once the new release file (promised for today) is available.
Bookmarks