[R-sig-DB] RODBC sqlSave appends rows from data frame in reverse order
Enrico Schumann
e@ @end|ng |rom enr|co@chum@nn@net
Wed Nov 20 17:34:36 CET 2013
On Wed, 20 Nov 2013, "Chris" <cs using incentive-investing.com> writes:
> Hi,
>
> I append rows to a table in MySQL with sqlSave from RODBC package. The data
> frame that is saved is ordered by date ascending (first column) as is the
> table in the DB. When I send the whole data frame at once, the data frame is
> appended in reverse order. That means the row with the newest date in the
> data frame is the first row appended to the table, while the row with oldest
> date will be last row in the table. OK, I thought that "append" just orders
> by date descending and that is why the reverse ordering happens. But when I
> send each row of the data frame using a for-loop the result is the same: The
> first row send is the last row in the table, the second row send, is the
> second last row in the table.
>
> My solution is to run the for loop from last to first row of the data frame
> but I am looking for an explanation why append works like this and if it's
> possible to change this in some setting.
>
In MySQL, you never have a guarantee in which order the rows will be
retrieved unless you specify it (eg, "SELECT * FROM table ORDER BY
column;").
[...]
>
> Thank you
>
> Chris
>
--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net
More information about the R-sig-DB
mailing list