efilltableparams.pp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. (******************************************************************************
  2. * *
  3. * (c) 2005 CNOC v.o.f. *
  4. * *
  5. * File: eFillTableParams.pp *
  6. * Author: Joost van der Sluis ([email protected]) *
  7. * Description: SQLDB example and test program *
  8. * License: GPL *
  9. * *
  10. ******************************************************************************)
  11. program eFillTableParams;
  12. {$mode objfpc}{$H+}
  13. uses
  14. Classes, sysutils,
  15. sqldb,
  16. SqldbExampleUnit;
  17. var i : integer;
  18. begin
  19. ReadIniFile;
  20. CreateFConnection;
  21. CreateFTransaction;
  22. CreateFQuery;
  23. with Fquery do
  24. begin
  25. SQL.Clear;
  26. SQL.Add('insert into FPDEV ( id, Name, Email, BirthDate) ');
  27. SQL.Add(' values ( :id, :name, :email, :birthdate ) ');
  28. for i := 2 to 4 do
  29. begin
  30. params.ParamByName('id').asinteger := i;
  31. params.ParamByName('name').asstring := FPdevNames[i];
  32. params.ParamByName('email').AsString := FPdevEmails[i];
  33. params.ParamByName('birthdate').AsDateTime := FPdevBirthDates[i];
  34. ExecSql;
  35. end;
  36. for i := 5 to 7 do
  37. begin
  38. if dbtype <> 'oracle' then
  39. sql[1] := 'values ('+inttostr(i)+ ', ' +
  40. '''' +FPdevNames[i]+ ''', ' +
  41. '''' +FPdevEmails[i]+ ''', ' +
  42. '''' +FormatDateTime('MM-DD-YYYY',FPdevBirthDates[i])+ ''')'
  43. else
  44. sql[1] := 'values ('+inttostr(i)+ ', ' +
  45. '''' +FPdevNames[i]+ ''', ' +
  46. '''' +FPdevEmails[i]+ ''', ' +
  47. '''' +FormatDateTime('DD-MMM-YYYY',FPdevBirthDates[i])+ ''')';
  48. ExecSql;
  49. end;
  50. end;
  51. Ftransaction.CommitRetaining;
  52. Fquery.Free;
  53. Ftransaction.Free;
  54. Fconnection.Free;
  55. end.