fpc/fcl/db/sqldb/examples/fedittable.pp
joost 772c36ae7a - Fix for TParam.SetDataType
- Implemented TSQLQuery.UpdateSQL .DeleteSQL and .InsertSQL
  Added example to fedittable.pp
- Fix for TSQLQuery.ExecSQL if no database is assigned
- TSQLQuery.ApplyRecUpdate now uses parameters
- Fixed handling of ftFixedChar parameters with IBConnection
- Clarified IBConnection parameters-error message

git-svn-id: trunk@3288 -
2006-04-19 22:24:04 +00:00

71 lines
2.1 KiB
ObjectPascal

(******************************************************************************
* *
* (c) 2005 CNOC v.o.f. *
* *
* File: fEditTable.pp *
* Author: Joost van der Sluis (joost@cnoc.nl) *
* Description: SQLDB example and test program *
* License: GPL *
* *
******************************************************************************)
program fEditTable;
{$mode objfpc}{$H+}
uses
Classes, sysutils,
sqldb,
SqldbExampleUnit;
begin
ReadIniFile;
CreateFConnection;
CreateFTransaction;
CreateFQuery;
Fconnection.Transaction := Ftransaction; //all updates are performed in this transaction
with Fquery do
begin
SQL.Clear;
SQL.Add('select * from FPDEV');
// With these lines commented out, TSQLQuery creates the update, delete and insert
// queries itself.
// For more complex queries, though, it could be nessecary to provide these queries
// here
// UpdateSQL.add('update fpdev set name=:name, birthdate=:birthdate where id=:OLD_id');
// DeleteSQL.add('delete from fpdev where id=:OLD_id');
// InsertSQL.add('insert into fpdev(id,name,email,birthdate) values (:id,:name,:email,:birthdate)');}
open;
Edit;
FieldByName('name').AsString := FPdevNames[1];
FieldByName('birthdate').AsDateTime := FPdevBirthDates[1];
Post;
Append;
FieldByName('id').AsInteger := 8;
FieldByName('name').AsString := FPdevNames[8];
FieldByName('email').AsString := FPdevEmails[8];
FieldByName('birthdate').AsDateTime := FPdevBirthDates[8];
post;
ApplyUpdates;
end;
Ftransaction.Commit;
Fquery.Free;
Ftransaction.Free;
Fconnection.Free;
end.