Re: [sqlite] ORDER of export on a SELECT

2013-05-02 Thread Gert Van Assche
Thanks for the advice, both. In the mean time we know that it indeed
something else causing the problem.

gert


2013/5/2 Simon Slavin 

>
> On 2 May 2013, at 9:26am, Gert Van Assche  wrote:
>
> > I have a table with 2 fields that need to be exported to 2 TXT files but
> > the order of the lines in the export should be exactly the same as in the
> > table.
>
> Tables do not have order.  Really.  A table is a set of rows, not an
> ordered set of rows.  If you do not specify ORDER BY on a unique set of
> values, the same SELECT can returns the same rows in different orders.
>
> > I tried to do it like this:
> > SELECT [FieldA] FROM [T1] ORDER BY rowid;
> > and
> > SELECT [FieldB] FROM [T1] ORDER BY rowid;
> > but the rowid order is not followed. The two TXT files that are created
> are
> > not in sync.
>
> If you have unique values in rowid, and really are doing those two
> commands in the same transaction (so nothing can write to the table between
> them), and getting rows returned in different orders, something is weird
> about your setup.
>
> In your software do
>
> SELECT [FieldA],[FieldB] FROM [T1] ORDER BY rowid
>
> Use your software to make one text file from the first values and another
> from the second values.  It will be faster too !
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] ORDER of export on a SELECT

2013-05-02 Thread Simon Slavin

On 2 May 2013, at 9:26am, Gert Van Assche  wrote:

> I have a table with 2 fields that need to be exported to 2 TXT files but
> the order of the lines in the export should be exactly the same as in the
> table.

Tables do not have order.  Really.  A table is a set of rows, not an ordered 
set of rows.  If you do not specify ORDER BY on a unique set of values, the 
same SELECT can returns the same rows in different orders.

> I tried to do it like this:
> SELECT [FieldA] FROM [T1] ORDER BY rowid;
> and
> SELECT [FieldB] FROM [T1] ORDER BY rowid;
> but the rowid order is not followed. The two TXT files that are created are
> not in sync.

If you have unique values in rowid, and really are doing those two commands in 
the same transaction (so nothing can write to the table between them), and 
getting rows returned in different orders, something is weird about your setup.

In your software do

SELECT [FieldA],[FieldB] FROM [T1] ORDER BY rowid

Use your software to make one text file from the first values and another from 
the second values.  It will be faster too !

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] ORDER of export on a SELECT

2013-05-02 Thread Richard Hipp
On Thu, May 2, 2013 at 4:26 AM, Gert Van Assche  wrote:

> All, I
>
> I have a table with 2 fields that need to be exported to 2 TXT files but
> the order of the lines in the export should be exactly the same as in the
> table.
> I tried to do it like this:
>  SELECT [FieldA] FROM [T1] ORDER BY rowid;
> and
>  SELECT [FieldB] FROM [T1] ORDER BY rowid;
> but the rowid order is not followed. The two TXT files that are created are
> not in sync.
>

"ORDER BY rowid" should always be honored.  If you have a case where it is
not, that is a bug.  Please send us sufficient information to reproduce the
problem and we will look into it.



>
> Is this normal or is there another way to address this?
>
> thanks for your help,
>
> Gert
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] ORDER of export on a SELECT

2013-05-02 Thread Gert Van Assche
All, I

I have a table with 2 fields that need to be exported to 2 TXT files but
the order of the lines in the export should be exactly the same as in the
table.
I tried to do it like this:
 SELECT [FieldA] FROM [T1] ORDER BY rowid;
and
 SELECT [FieldB] FROM [T1] ORDER BY rowid;
but the rowid order is not followed. The two TXT files that are created are
not in sync.

Is this normal or is there another way to address this?

thanks for your help,

Gert
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users