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

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

Technically there isn't any "order" for the return columns. They aren't returned as an Array -- they're just properties on an Object instance (a "generic object"). The random order you're seeing is the behavior of the for..in loop iterating over the properties of the object. Unfortunately, with a for..in loop there is no guaranteed order for iterating over properties (and, as you've seen, it tends to vary wildly).
The only solution is to create your own list of the column names and sort it the way you want to, then use that to create your output. For example, use the for..in loop to loop over the properties, but rather than actually get the values, just dump the column names into an Array:
var columnName="";
var columns = [];
for (columnName in selResults.data[i]) {
    columns.push(columnName);
columns = columns.sort(); // just uses the default alphabetical sort -- you would customize this if desired
var j = 0;
for (j = 0; j < columns.length; j++) {
    columnName = columns[j];
    output+=columnName + ":" + selResultsdata[i][columnName] + ";";

Similar Messages

  • How do I change the order of columns in the responses table?

    How do i change the order of columns in the responses table in FormsCentral?  The default setting puts them in reverse order!

    Hi,
    The issue with the default ordering of columns in the response table is something that we hope to address in the next update to FormsCentral. In the meantime, you can reorder the columns by selecting them then click/drag using the gray area above the column name. As shown below, an orange marker will show you where the columns will be placed when you release the mouse button.
    Sorry for the inconvenience.
    Regards,
    Brian

  • Is there any performance difference in the order of columns referencing index?

    I wish to find out if there is any performance difference or efficiency in specifying those columns referencing index(es) first in the WHERE clause of SQL statements. That is, whether the order of columns referencing the index is important???.
    E.g. id is the column that is indexed
    SELECT * FROM a where a.id='1' and a.name='John';
    SELECT * FROM a where a.name='John' and a.id='1';
    Is there any differences in terms of efficiency of the 2 statements??
    Please advise. Thanks.

    There is no difference between the two statements under either the RBO or the CBO.
    sql>create table a as select * from all_objects;
    Table created.
    sql>create index a_index on a(object_id);
    Index created.
    sql>analyze table a compute statistics;
    Table analyzed.
    sql>select count(*)
      2    from a
      3   where object_id = 1
      4     and object_name = 'x';
    COUNT(*)
            0
    1 row selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=29)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=1 Card=1 Bytes=29)
       3    2       INDEX (RANGE SCAN) OF 'A_INDEX' (NON-UNIQUE) (Cost=1 Card=1)
    sql>select count(*)
      2    from a
      3   where object_name = 'x'   
      4     and object_id = 1;
    COUNT(*)
            0
    1 row selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=29)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=1 Card=1 Bytes=29)
       3    2       INDEX (RANGE SCAN) OF 'A_INDEX' (NON-UNIQUE) (Cost=1 Card=1)

  • Does the order of columns in an index matter?

    Hi,
    I have a table having composite index, five columns. (col1,col2,col3,col4,col5)
    Currently , my index is beginning with the column which having low distinct values and so on.
    ( in my case the first column have 1 distinct values due to functional behavior ). the second column have 3 distinct values , the third column have many distinct value ( half of the table).
    There are many DML queries on this table with different clauses.
    Examples:
    query 1 : where col1 =val1 and col2 = val2
    query 2 : where (col3,col4) in ( select col1,col2 from another_table ) ( for this we can add col1 =val1 and col2 = val2)
    My question is : what this best way to create index on this case ?
    The order of columns on index depends on its distinct values?
    Thanks

    BIJGA wrote:
    Hi,
    I have a table having composite index, five columns. (col1,col2,col3,col4,col5)
    Currently , my index is beginning with the column which having low distinct values and so on.
    ( in my case the first column have 1 distinct values due to functional behavior ). the second column have 3 distinct values , the third column have many distinct value ( half of the table).
    There are many DML queries on this table with different clauses.
    Examples:
    query 1 : where col1 =val1 and col2 = val2
    query 2 : where (col3,col4) in ( select col1,col2 from another_table ) ( for this we can add col1 =val1 and col2 = val2)
    My question is : what this best way to create index on this case ?CREATE INDEX
    The order of columns on index depends on its distinct values? yes
    Handle:     BIJGA
    Status Level:     Newbie (5)
    Registered:     Aug 24, 2009
    Total Posts:     66
    Total Questions:     18 (14 unresolved)
    I extend my condolences to you since you rarely get answers to your questions.

  • What is the order of restoring backups in sharepoint 2010

    Hi
    production form has 
    2 web application ,custom solutions and service applications configured(user profile,serarch)
    here what is the order of restoring backups in  my newly created test form
    adil

    Hi
    in my production environment when i create new web application how
    the custom solution included in _layouts folder?
    this  is the information from systemsettings>farmsolutions
    Name: xyz.scan.wsp
    Type: Core Solution
    Contains Web Application Resource: Yes
    Contains Global Assembly: Yes
    Contains Code Access Security Policy: No
    Deployment Server Type: Front-end Web server
    Deployment Status: Deployed
    Deployed To: http://spwf01:81/;
    http://spwf01:83/; http://spwf01/;
    http://spwf01:84/; http://spwf01:82/
    here  there is no webapplication with port 85 , but when i create new web application with port 85
    this solution exists in _layouts folder
    adil

  • Changing the order of columns in a table

    Can anyone tell me how to change the order of column in a table.
    I want a new column to be added in a table in 2nd position.
    Is there any way out for it?

    1) Does this have something to do with security? If not, it really ought to be posted in a more appropriate forum (Database - General for example).
    2) Why? If you care about the order of columns in a table, you're almost certainly doing something wrong. You can control the order of columns in a view, however, so you can put a view layer on top of the table to present the columns in a friendly fashion.
    3) Not without recreating the table. You can use the DBMS_REDEFINITION package to recreate the table with zero or minimal downtime but behind the scenes, you're really just creating a new table, copying the data over, dropping the old table, and renaming the new table to use the old table's name. DBMS_REDEFINITION does some extra work to track changes so that the original table can be available until the last possible moment.
    Justin

  • While defining a columnar table, what is the purpose of column store type

    Hi folks
    I have two questions related to columnar table definition.
    1. What is the purpose of column store type.
    While defining a columnar table, what is the purpose of column store type (STRING ,CS_FIXEDSTRING,CS_INT etc) , when I define a table using the UI I see that the column is showing STRING but when I goto EXPORT SQL it does not show.  Is this mandatory or optional ?
    2.VARCHAR Vs. CHAR - In the UI when I create the table I do not see the CHAR option , but I do see lot of discussion where people are using CHAR for defining the columnar table. Not sure why UI dropdown does not show it. I also read that we should avoid using VARCHAR as those columns are not compressed, is that true, I thought the column store gives compression for all the columns. Are there certain columns which cannot be compressed .
    Please let me know where I can find more information about these two questions.
    Poonam

    Hi Poonam
    the CS_-data types are the data types that are used internally in the column store. They can be supplied but it is not at all required or recommended to do so.
    SAP HANA will automatically use the correct CS_-data type for every SQL data type in your table definitions.
    To be very clear about this: don't use the CS_-data types directly. Just stick to the SQL data types.
    Concerning VARCHAR vs CHAR: fixed character data types are not supported anymore and don't show up anymore in the documentation.
    I have no idea why you believe that VARCHAR columns are not compressed but this is just a myth.
    create column table charcompr (fchar char(20), vchar varchar(20));
    insert into charcompr (
        select lpad ('x', to_int (rand()*20), 'y'), null from objects cross join objects);
    -- same data into both columns
    update charcompr set vchar = fchar;
    -- perform the delta merge and force a compression optimization
    merge delta of charcompr;
    update charcompr with parameters ('OPTIMIZE_COMPRESSION' ='FORCE');
    -- check the memory requirements
    select COLUMN_NAME, MEMORY_SIZE_IN_TOTAL, UNCOMPRESSED_SIZE, COUNT, DISTINCT_COUNT, COMPRESSION_TYPE
    from m_cs_columns where table_name ='CHARCOMPR'
    COLUMN_NAME    MEMORY_SIZE_IN_TOTAL    UNCOMPRESSED_SIZE   COUNT   DISTINCT_COUNT  COMPRESSION_TYPE
    FCHAR       3661                    70285738            6692569 20              RLE
    VCHAR       3661                    70285738            6692569 20              RLE
    We see: compression and memory requirements are the same for both fixed and variable character sizes.
    - Lars

  • What is the field and table name to describe -Employee Hourly Rate or Emplo

    Hi,
    Can any one please tell me what is the field and table name to describe 
    Employee Hourly Rate or Employee Rate.
    Thanks for ur time.
    Murali.

    Hi Murali,
    The hourly rate is tied to a Wagetype & maintained in Infotype 0008. The database table is PA0008.
    the field could vary depending on the No of wagetypes maintained.
    regards,
    Suresh Datti

  • Change the order of columns in a report

    hi all.
    i can't change the order of columns in a report not just by altering the select statement. where can i change it?
    thanks.

    hi master
    sir i use 6i report i see full report but i culd not found
    report region and report attributes
    sir please give me step or idea or tree where report region and report attrinutes"
    thanking you
    aamir

  • What's the difference between "Full Name" and "Account Name"

    Just re-install a new OS X Lion. On the "Create Your Computer Account" screen, what's the difference between "Full Name" and "Account Name"?

    Your computer name by default would be "John David Appleseed's Macbook Pro"
    But you can always change that in System Preferences->Sharing
    And yes, the first account you set up will be an administrator.

  • What is the best way to name a file?

    What is the best way to name a file? Use "_" so that the characters make one, long name? Why do that?

    Another take on naming files, particularly image files, is like this:
    I use a file remaning application like Name Mangler to back, sequentially rename the photos.  I put them in a folder with a similar name.  Using the format I do, YYYY-MM-DD- Description-001.jpg, they are easy to sort by date by sorting alphanumerically.
    OT

  • Check Print in the order of Vendor names

    Hello,
       Currently checks are being printed in the order of vendor acc numbers, they want to print them in the order of their names. for e.g is ven acc #1 has name Boy and vendor acc # 2 has name Apple , check number 1 should print Apple or ven #2 followed by ven # 1.
    please let me know how this can be done.
    Thanks very much in advance.

    Hi,
    Easiest way is to take help from your ABAPer..
    Cheers
    Raghu

  • What does the top level instance name "iop" mean?

    What does the top level instance name "iop" mean?

    Dear Humility,
    In general term higher level account group means which account group is used to the higher level customers in the Customer Hierarchy process.
    Or
    Which of these account groups are valid for higher-level customers in the hierarchy.
    I hope this will help you,
    Regards,
    Murali.

  • What is the order of execution of global transfer routine where multiple routines are involved?

    Hi,
    Suppose we have start routine, transformation routines and end routine defined between datasource and data target, and also we have a global transfer routine created on an infoobject.
    What is the order of execution of routines in this scenerio?
    Also if conversion routine like ALPHA is defined for an Infoobject, when does this come into flow.?
    Please enlighten me.
    Thanks,
    Akshara

    Hello Akshara ,
    The sequence of routines are as
    1. Start Routine
    2. Master Data Look Up or
    3. Field Level Routine
    4. End Rountine
    Apart from this , there is Expert routine, which is used in special cases, when there are not the sufficient functions to perform a transformation. It can be used as a interim solution , and it performs all the  functions of Start routine, end routine , field routine.
    Note : if you have created  transformation, and then created Expert routine, then system will delete all the existing transformations.
    Further to this, you can explore more, by debug the transformation as suggested by Vijay Kumar.
    Hope this helps !
    Regards
    YN

  • HT4910 documents edited on iphone, ipad, & mac   what is the order of creation and editing and must each change be manually initiated to update the icloud

    documents edited on iphone, ipad, & mac   what is the order of creation and editing and must each change be manually initiated to update the icloud?

    No idea what you mean by the firsy part of your question.
    Documents edited on the Mac need manually uloading to iCloud at iCloud.com,documents edited on the mobile devices are updated automatically.

Maybe you are looking for

  • Dnt want Auto Multiple Ship Costs items for Same Vendor

    Hi All, I have a problem.. In my shipment my header as well as Legs are cost relevant. And i have given automatic determination of item categories in my shipment costs. Now the problem is when i have say 2 stages in my route den in my shipment costs

  • Alignment problem in sending an attachment file as a mail

    Hi,   My requirement is to send a mail where i have the data in an internal table. the .txt attachment file is sent properly no problem in that. But the text inside the file is not alligned properly. For eg if i have 5 records in the internal table w

  • XEmacs problems in OS 10.5.7

    After updating to 10.5.7, characters I type into XEmacs are scrambled. For example, when I enter 'bcd", I see '071' on the screen. I didn't have any problem with 10.5.6.

  • How to launch photoshop plug-ins under Lightroom?

    Do Somebody know a way how to launch Adobe Photoshop plug-ins under Lightroom? Especially the case is interesting when there is only Lightroom and there is not an installed copy of Photoshop. There are some 3th party favorite Photoshop's plug-ins (so

  • Windows 7 Not recognizing 10.5 Disk

    I got thorough the installation of seven in bootcamp, and then it did some updates. Afterwards, i inserted the 10.5 install disk, and nothing happened. I went to look at it, but it said it was empty. Ive tried auto opening, running as admin, nothing