1 |
|
unit Test1; |
2 |
+ |
{$IFDEF MSWINDOWS} |
3 |
+ |
{$DEFINE WINDOWS} |
4 |
+ |
{$ENDIF} |
5 |
|
|
6 |
|
{Create and Drop a Database} |
7 |
|
{ |
14 |
|
A basic query is performed and finally the database dropped. |
15 |
|
} |
16 |
|
|
17 |
< |
{$mode objfpc}{$H+} |
17 |
> |
{$IFDEF FPC} |
18 |
> |
{$mode delphi} |
19 |
|
{$codepage utf8} |
20 |
+ |
{$ENDIF} |
21 |
|
|
22 |
|
interface |
23 |
|
|
32 |
|
private |
33 |
|
procedure DoQuery(Attachment: IAttachment); |
34 |
|
public |
35 |
< |
function TestTitle: string; override; |
36 |
< |
procedure RunTest(CharSet: string; SQLDialect: integer); override; |
35 |
> |
function TestTitle: AnsiString; override; |
36 |
> |
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; |
37 |
|
end; |
38 |
|
|
39 |
|
implementation |
62 |
|
end; |
63 |
|
end; |
64 |
|
|
65 |
< |
function TTest1.TestTitle: string; |
65 |
> |
function TTest1.TestTitle: AnsiString; |
66 |
|
begin |
67 |
|
Result := 'Test 1: Create and Drop a Database'; |
68 |
|
end; |
69 |
|
|
70 |
< |
procedure TTest1.RunTest(CharSet: string; SQLDialect: integer); |
70 |
> |
procedure TTest1.RunTest(CharSet: AnsiString; SQLDialect: integer); |
71 |
|
var DPB: IDPB; |
72 |
|
Attachment: IAttachment; |
73 |
< |
DBInfo: IDBInformation; |
69 |
< |
ConType: integer; |
70 |
< |
DBFileName: string; |
71 |
< |
DBSiteName: string; |
73 |
> |
createSQL: AnsiString; |
74 |
|
begin |
75 |
|
writeln(OutFile,'Creating a Database with empty parameters'); |
76 |
|
Attachment := FirebirdAPI.CreateDatabase('',nil,false); |
79 |
|
else |
80 |
|
Attachment.DropDatabase; |
81 |
|
|
82 |
+ |
writeln(OutFile,'Creating a Database using an SQL Statement'); |
83 |
+ |
createSQL := Format('CREATE DATABASE ''%s'' USER ''%s'' PASSWORD ''%s'' DEFAULT CHARACTER SET %s', |
84 |
+ |
[Owner.GetNewDatabaseName, Owner.GetUserName, Owner.GetPassword, CharSet]); |
85 |
+ |
Attachment := FirebirdAPI.CreateDatabase(createSQL,SQLDialect); |
86 |
+ |
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_db_SQL_Dialect])); |
87 |
+ |
|
88 |
+ |
writeln(OutFile,'Dropping Database'); |
89 |
+ |
if Attachment <> nil then |
90 |
+ |
Attachment.DropDatabase; |
91 |
+ |
|
92 |
|
writeln(OutFile,'Creating a Database with a DPD'); |
93 |
|
DPB := FirebirdAPI.AllocateDPB; |
94 |
|
DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName); |
112 |
|
writeln(OutFile,'Create Database Failed'); |
113 |
|
Exit; |
114 |
|
end; |
115 |
< |
DBInfo := Attachment.GetDBInformation([isc_info_db_id]); |
104 |
< |
DBInfo[0].DecodeIDCluster(ConType,DBFileName,DBSiteName); |
105 |
< |
writeln(OutFile,'Database ID = ', ConType,' FB = ', DBFileName, ' SN = ',DBSiteName); |
106 |
< |
DBInfo := Attachment.GetDBInformation([isc_info_ods_version]); |
107 |
< |
write(OutFile,'ODS major = ',DBInfo[0].getAsInteger); |
108 |
< |
DBInfo := Attachment.GetDBInformation([isc_info_ods_minor_version]); |
109 |
< |
writeln(OutFile,' minor = ', DBInfo[0].getAsInteger ); |
115 |
> |
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version])); |
116 |
|
|
117 |
|
{Querying Database} |
118 |
|
DoQuery(Attachment); |