Database syntax

Michael Doub mike at doub.com
Tue Dec 20 14:31:07 EST 2011


Could I trouble someone for an example of how to insert a row in a SQLite database with a live code array then update that same record with an updated array?

put revOpenDatabase("sqlite", thePath, , , , ) into tID
put the "CREATE TABLE ContactData ( " & \
            "myKey integer PRIMARY KEY autoincrement," & \
            "RecordType text," & \
            "RecID text," & \
            "Name text," & \
            "GroupNbr text," & \
            "LastContact, text," & \
            "DaysTill text," & \
            "DataArray blob) "  into tSQL
revExecuteSQL tID, tSQL   
   
I think that I am ok up to here.   I want to insert a record that has a RecordType of "0", all other fields empty except I want to put an livecode array into DataArray.

This will get the array into text:
 put arrayEncode(tSettings) into tSettings;  put base64Encode(tSettings) into tSettings

I am unclear on how to do the insert or an update.  Do I somehow have to create a long SQL statement with the actual data in the statement? 

A second database question.  Does the myKey variable automatically get set to a unique value when data is inserted? 

Thanks in advance,
    Mike




More information about the Use-livecode mailing list