(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
[inherit('psqlitedir:sqlite', 'psqlitedir:psqlite')]
program list_after_2(input, output);

%include 'address.pas'

var
   con : sqlite_ptr;
   sel : sqlite_stmt_ptr;
   count : integer;
   res : array [1..1000] of address;
   i : integer;

begin
   con := psqlite_open('address.db');
   sel := psqlite_prepare(con, 'SELECT id,name,address FROM address');
   count := 0;
   while psqlite_step_query(sel) do begin
      count := count + 1;
      res[count].id := psqlite_column_int(sel, 0);
      res[count].name := psqlite_column_text(sel, 1);
      res[count].address := psqlite_column_text(sel, 2);
   end;
   psqlite_finalize(sel);
   psqlite_close(con);
   for i := 1 to count do begin
      writeln(res[i].id, '|', res[i].name, '|', res[i].address);
   end;
end.
