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