Sqlite table List and column

edited July 2015 in Newbie Questions
Hi all,

I am trying to get a list of all the tables in my sqlite database and a column to show. I have setupItemA as below:
setupItemA: function(inSender, inEvent) {

var r = this.dataA[inEvent.index]; //set data arry values to record
if (r) {
this.$.Account.setContent(r.Account);
this.$.Type.setContent(r.Type);
this.$.index.setContent(r.id);
this.$.Balance.setContent(r.Balance);
this.$.Location.setContent(r.Location);
this.$.Drawing.setContent(r.Drawing);

return true;
}
},


When I run the italicized section of doQueryA below, I get a list of all table names e.g 7 rows.

When I run the bold section of doQueryA, by manually entering any table name (e.g Booty) from the list as dataValue3 it gives me one row with the table name and column value, exactly what I need.

The problem is: I would like for each row, dataValue3 to hold the name of a table from the list as the rows are rendered such that I have 7 rows.
doQueryA: function(inSender, inEvent) {
dataValue3 = "Booty";
//var mytext = 'SELECT name as Location FROM sqlite_master WHERE type = "table" AND name NOT LIKE "%WebKit%" ORDER BY name';

var mytext = 'SELECT name as Account, Balance FROM sqlite_master, "' + dataValue3 +
'" WHERE sqlite_master.name = "' + dataValue3 + '".Account AND name NOT LIKE "%WebKit%" ORDER BY name';

this.db.transaction(
enyo.bind(this,(function (transaction) {
transaction.executeSql(mytext, [], enyo.bind(this,this.showDataResponseA), enyo.bind(this,this.errorHandlerA));
}))
);
},
Regards

Comments

  • Edited for code formatting
  • I think you want to perform a JOIN. You'll want to look at StackOverflow or a SQL reference. It's not really an Enyo question, unless I wasn't following you correctly.

    Maybe http://www.sql-join.com/ ?
  • Thanks theryanjduffy for the formatting and RoySutton for the pointer.

    Since the doQueryA renders a row with dataValue3 = "Booty", I thought maybe it may be possible to let dataValue3 be a variable that makes use of this.$.Account.getContent(); since I setup the this.$.Account.setContent(r.Account); as the account name displayed per row.

    There is a question in StackOverflow which is similar to what I am trying to achieve i.e list all tables and their column(s) but there has been no answer to it.

    regards
  • You can always bind the value of dataValue3 to this.$.account.content if you want to create that connection.
Sign In or Register to comment.