Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- {$mode objfpc}{$H+}
- uses
- pqconnection, sqldb;
- var
- d: TPQConnection;
- t: TSQLTransaction;
- q: TSQLQuery;
- begin
- d := TPQConnection.Create(nil);
- t := TSQLTransaction.Create(d);
- q := TSQLQuery.Create(d);
- try
- t.DataBase := d;
- q.DataBase := d;
- q.Transaction := t;
- d.HostName := '127.0.0.1';
- d.DatabaseName := 'postgres';
- d.UserName := 'postgres';
- d.Password := 'postgres';
- q.SQL.Text := 'select * from test';
- q.Open;
- q.Insert;
- q.FieldByName('id').AsInteger := 2;
- q.FieldByName('fieldtext').Clear;
- q.Post;
- q.ApplyUpdates;
- try
- t.Commit;
- except
- t.Rollback;
- raise;
- end;
- finally
- d.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment