-
23 Feb 2010 7:14 AM #21
SQLiteStore - VIEWS Not recognized
SQLiteStore - VIEWS Not recognized
Hello Pranke,
So I followed your instructions and my suspicions were right:
As for rs, its showing we rs is undefined and I can't seem to catch what sql statement is being sent off to the SQLite database. I'm getting this suspicion that Ext.Air is doing something like the below, but I cna't prove it.Code:SQLError: 'Error #3115: SQL Error.', details:'no such table: 'vw_admins'', operation:'execute', detailID:'2013' at [Eval script](e) (iApplication/lib/ext/ext-all-debug.js:13981) at [Eval script](e) (iApplication/lib/ext/ext-all-debug.js:32611) at [Eval script]() (iApplication/lib/ext/ext-all-debug.js:32266) at [Eval script](forceAll, q) (iApplication/lib/ext/ext-all-debug.js:58267) at [Eval script]() (iApplication/lib/ext/ext-all-debug.js:58350) at h(e) (iApplication/lib/ext/ext-all-debug.js:2646)
Code:select * from sql_master where table_name= xyz
-
23 Feb 2010 7:25 AM #22
I see that you use "CREATE VIEW" to create the view. I am not sure, but I think, that the SQLiteStore does not support a real view. Try to use a normal table and the SQLiteStore with the property api. api got 4 propertys - set each one to false, so no changes are made to the database.
-
24 Feb 2010 1:35 AM #23
Hello Pranke,
This is odd, because Makana had previously stated that you could select from a view!?
Also a view is simply a predefined select statement. Therefore you can do a select * from my_view, which is exactly what happens in the code:
Code:selectBy : function(clause, args){ var sql = "SELECT * FROM " + this.name; if(clause){ sql += ' ' + clause; } args = args || {}; return this.conn.queryBy(sql, args); },
-
24 Feb 2010 1:50 AM #24
You can!
Seems like the view isn't created. It should not be a problem with the store. Or you have a quoting problem.... don't know exactly if the underlined single quotes are always in that type of error message...
But you quote a lot in qour sql strings. Why? Maybe there is a problem with this....
Programming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)
Enhanced ExtJS adapter for Adobe AIR
-
24 Feb 2010 2:38 AM #25
SQL example to create working view
SQL example to create working view
Hello Makana,
Could you provide me an example SQL CREATE VIEW whihc works for you. I've tried all the the possible combination, single quote, double quote, no quotes and I'll still getting thsi error. I've even tried thing ssuch as 'main.MYVIEW'
Thanks
Jack
-
24 Feb 2010 3:00 AM #26
Is the view available in your database? With which name, with which column names? Use your SQLiteManager addon for firefox to inspect.
And then post your code you use to read from the db, please! Does this error appear on load method? or only on insert/update/delete?
Or wait a moment...
I think, I've an idea... is it possible, that you want to auto create the "table" on creating the store? Configure your store with createTable: false! Make sure, the Ext.sql.AirConnection.createTable method isn't called!
But that should be by default in current ext-air-debug file in this thread.
Just FYI, a new version with a completly reviewed SQLiteStore/connection etc. is coming soon...Programming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)
Enhanced ExtJS adapter for Adobe AIR
-
24 Feb 2010 3:43 AM #27
Hello Makana,
I've followed all of you instructions. This is a read-only store, so I used your api extension as such:
Yes my view is avaialble in the SQLiteManager add-on for firefox. When I do a select * from VW_ADMINS I get all the records inside that view. For the sake of avoid upper/lower case issues I've rewriten everything to upper case, therefore my view definition is as suchCode:store: new Ext.sql.SQLiteStore({ conn: iApplication.module.DB ,api:{create:false ,update:false ,destroy:false } ,createTable: false ,tableName: 'VW_ADMINS' ,key: 'id' ,fields: [{name: 'id', type: 'int'} ,{name: 'text', type: 'string'} ] })
Thanks JackCode:CREATE VIEW "VW_ADMINS" AS SELECT ADMINISTRATOR_ID as id, ADMINISTRATOR_NAME as text FROM ORI_ADMINISTRATORS WHERE ADMINISTRATOR_TYPE = "COUNTRY" ORDER BY UPPER(ADMINISTRATOR_NAME) ASC
ps - looking forward to the new Store :-)
-
24 Feb 2010 4:03 AM #28
Hello Makana,
I've followed all of you instructions. This is a read-only store, so I used your api extension as such:
Yes my view is avaialble in the SQLiteManager add-on for firefox. When I do a select * from VW_ADMINS I get all the records inside that view. For the sake of avoid upper/lower case issues I've rewriten everything to upper case, therefore my view definition is as suchCode:store: new Ext.sql.SQLiteStore({ conn: iApplication.module.DB ,api:{create:false ,update:false ,destroy:false } ,createTable: false ,tableName: 'VW_ADMINS' ,key: 'id' ,fields: [{name: 'id', type: 'int'} ,{name: 'text', type: 'string'} ] })
Yes indeed the error originates from the load method:Code:CREATE VIEW "VW_ADMINS" AS SELECT ADMINISTRATOR_ID as id, ADMINISTRATOR_NAME as text FROM ORI_ADMINISTRATORS WHERE ADMINISTRATOR_TYPE = "COUNTRY" ORDER BY UPPER(ADMINISTRATOR_NAME) ASC
And I'm using the basic selectBy as defined in the modified version:Code:load : function(options) { options = options || {}; this.storeOptions(options); if(this.sortInfo && this.remoteSort){ var pn = this.paramNames; options.params = options.params || {}; options.params[pn.sort] = this.sortInfo.field; options.params[pn.dir] = this.sortInfo.direction; } try { return this.execute('read', null, options); // <-- null represents rs. No rs for load actions. } catch(e) { this.handleException(e); return false; } },
Code:selectBy : function(clause, args){ var sql = "SELECT * FROM " + this.name; if(clause){ sql += ' ' + clause; } args = args || {}; return this.conn.queryBy(sql, args); },
Thanks Jack
ps - looking forward to the new Store :-)
-
24 Feb 2010 4:22 AM #29
please do an
in your selectBy function and look, what sql string is generated.Code:air.Introspector.Console.info(sql, args);
Programming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)
Enhanced ExtJS adapter for Adobe AIR
-
24 Feb 2010 5:05 AM #30
Hello Makana,
Here is the ouput of the Instrospector from the view, which returns the error table cannot be found:
And here is the result of another store which access a table.Code:[app:/country.html?session_id=2176900351995318][13:57:56] SELECT * FROM VW_ADMINS, [Array 0], [Arguments 2] 0 "SELECT * FROM VW_ADMINS" 1 [Array 0]
Ultimately, both are essential the same, and when copy/paste execute in SQLIteManager firefox add-on, it returns all the data as it should?Code:[app:/country.html?session_id=2176900351995318][13:59:41] SELECT * FROM ORI_DATABASES LIMIT 25, [Array 0], [Arguments 2] 0 "SELECT * FROM ORI_DATABASES LIMIT 25" 1 [Array 0]
Thanks Jack


Reply With Quote