Dennis, I really appreciate your patience and willingness to help.
Unfortunately, this still did not bring me to the expected solution. I
will give you a small algorithm of what I need to do and I'm sure after
this you'll know how to assist me.
1. I read a .csv file into a linked list of structures.
2. I examine eacch structure one after the other:
Compare the datetime filed of the structure aginst the current date. If
bigger (future), I skup to the next structure.
If smaller or equal, I check if a row with the same id field already
exists in the table:
Select * from tbl where id = id-in-struct.
If no such row exists, I insert a row according to the structure's
field, otherwise, based on another criteria I EITHER UPDATE THE row with
a new value on the second column or delete the row.
3. After this process, I free the structure from the linked list and
move to the next structure.
Because of the last section, I thought I need to make the date
comparison in C, but I may be wrong here.
However, if the comparison is made thru sqlite, how can I know if indeed
an insert, update or delete was processed so that I can free the
structures?
All the sql statements I use above are, of course, prepared statements
which I execute with wqlite3_step for the fields of each structure.
I hope I'm clear, this time.
Thanks, Rafi.

-----Original Message-----
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 14, 2007 5:21 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] date/time implementation question


Rafi Cohen wrote:
> Thanks Denis for your detailed explanation. My needs differ from the 
> example you gave. I need to compare the date on each row with the 
> current date, if the rowdate has passed then I either insert or update

> this row on a specific table, otherwise I leave this row for a future 
> check. So, the comparison has to be made in C and not sqlite, I think.
> Now, suppose I brought the rowdate to the format "YYYY-mm--dd
HH:MM:SS".
> In order to call strcmp() to compare with the current date, I need to
> bring the current date to the same format. How can I do this, or you
> have other ideas to make this comparison?
>   
Rafi,

There is no need for C in case you have given. A simple insert of 
selected data should do.

    insert or ignore into over_due
    select id from schedule
    where (due_date || ' ' || due_time) < datetime('now');

This uses one of sqlite's builtin date and time functions (see 
http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions ) to format 
the current time into an ISO format that can be compared directly with 
the concatenated fields from your existing table. The id of any records 
that meet the condition are inserted into the over_due table (or ignored

if they already exist in that table).

HTH
Dennis Cote



------------------------------------------------------------------------
-----
To unsubscribe, send email to [EMAIL PROTECTED]
------------------------------------------------------------------------
-----



-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.11/721 - Release Date:
3/13/2007 4:51 PM



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to