(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program test;

uses
   SQLDB, SQLite3Conn;

var
   con : TSQLite3Connection;
   tx : TSQLTransaction;
   ins, sel : TSQLQuery;

begin
   con := TSQLite3Connection.Create(nil);
   tx := TSQLTransaction.Create(con);
   con.DatabaseName := 'test.db';
   con.Transaction := tx;
   con.Open;
   tx.StartTransaction;
   ins := TSQLQuery.Create(nil);
   ins.DataBase := con;
   ins.SQL.Text := 'INSERT INTO multi(msg) VALUES(:msg)';
   ins.Params.ParamByName('msg').AsString := 'Hi from Pascal on Windows';
   ins.ExecSQL;
   if ins.RowsAffected <> 1 then begin
      writeln('INSERT error');
      halt;
    end;
   ins.Close;
   ins.Free;
   tx.Commit;
   sel:= TSQLQuery.Create(nil);
   sel.DataBase := con;
   sel.SQL.Text := 'SELECT id,msg FROM multi';
   sel.Open;
   while not sel.EOF do begin
      writeln(sel.FieldByName('id').AsInteger:1,' ',sel.FieldByName('msg').AsString);
      sel.Next;
   end;
   sel.Close;
   sel.Free;
   tx.Free;
   con.Close;
   con.Free;
end.
