Quantcast
Channel: Adobe Community : Popular Discussions - Archived Discussions
Viewing all articles
Browse latest Browse all 21156

What is the order of Column Names in Sqlite query results?

$
0
0

I am writing an application using Adobe Air, Sqlite, and Javascript.

 

After writing the following select statement:

          SELECT field1, field 2, field 3, field 4 FROM TableA;

I would like to get the columnName/data combination from each row -- which I do successfully with a loop:

          var columnName="";

          for (columnName in selResults.data[i]) {

               output+=columnName + ":" + selResultsdata[i][columnName] + ";";

               }

 

My issue is that the column names come out in a different order every time I run the query and never once have they come out in the desired order -- field 1, field 2, field 3, field 4.  If I run the query in Firefox's Sqlite Manager, the columns come out in the "proper" order. When I run them in Adobe Air, the order will be the same if I run the query mulitple times without closing the app.  If I make a change such as declaring the columnName variable with "" before the for column, or declare it as (var = columnName in selResults.data) , then the order changes.  If I shut down my app and re-open after lunch and run query, it comes out in another order.  At this time, I'm not interested in the order of the rows, just the order of the columns in each output row.  I've even tried assiging an index to columnName which seems to just pick up a single letter of the columnName.

 

I'm in the process of changing my HTML presentation of the data to assign a precise columnName to an HTML table title, but I'm reluctant to let go of the above concept as I think my separation of HTML/presentation and Javascript would be better if I could use the solution described above.

 

So, does anybody know how to force the order of the columnNames in my output -- or what I'm doing to cause it to come out in a different order?

 

Jeane


Viewing all articles
Browse latest Browse all 21156

Trending Articles