Guest User

Untitled

a guest
Sep 11th, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.74 KB | None | 0 0
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   pqconnection, sqldb;
  7.  
  8. var
  9.   d: TPQConnection;
  10.   t: TSQLTransaction;
  11.   q: TSQLQuery;
  12. begin
  13.   d := TPQConnection.Create(nil);
  14.   t :=  TSQLTransaction.Create(d);
  15.   q := TSQLQuery.Create(d);
  16.   try
  17.     t.DataBase := d;
  18.     q.DataBase := d;
  19.     q.Transaction := t;
  20.     d.HostName := '127.0.0.1';
  21.     d.DatabaseName := 'postgres';
  22.     d.UserName := 'postgres';
  23.     d.Password := 'postgres';
  24.  
  25.     q.SQL.Text := 'select * from test';
  26.     q.Open;
  27.     q.Insert;
  28.     q.FieldByName('id').AsInteger := 2;
  29.     q.FieldByName('fieldtext').Clear;
  30.     q.Post;
  31.     q.ApplyUpdates;
  32.     try
  33.       t.Commit;
  34.     except
  35.       t.Rollback;
  36.       raise;
  37.     end;
  38.   finally
  39.     d.Free;
  40.   end;
  41. end.
Advertisement
Add Comment
Please, Sign In to add comment