(* 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) *)
[inherit('sqlite', 'psqlite')]
program test(input, output);

var
   con : sqlite_ptr;
   ins, sel : sqlite_stmt_ptr;

begin
   con := psqlite_open('test.db');
   if con = 0 then begin
      writeln('Error in open: ', psqlite_errmsg(con));
      halt;
   end;
   ins := psqlite_prepare(con, 'INSERT INTO multi(msg) VALUES(?)');
   if ins = 0 then begin
      writeln('Error in prepare: ', psqlite_errmsg(con));
      halt;
   end;
   if not psqlite_bind_text(ins, 1, 'Hi from Pascal on VMS') then begin
      writeln('Error in bind: ', psqlite_errmsg(con));
      halt;
   end;
   if not psqlite_step_nonquery(ins) then begin
      writeln('Error in step: ', psqlite_errmsg(con));
      halt;
   end;
   sel := psqlite_prepare(con, 'SELECT id,msg FROM multi');
   if sel = 0 then begin
      writeln('Error in prepare: ', psqlite_errmsg(con));
      halt;
   end;
   while psqlite_step_query(sel) do begin
      writeln(psqlite_column_int(sel, 0):1, ' ', psqlite_column_text(sel, 1));
   end;
   psqlite_finalize(sel);
   psqlite_close(con);
end.
