1 |
|
unit Test1; |
2 |
|
{$IFDEF MSWINDOWS} |
3 |
|
{$DEFINE WINDOWS} |
4 |
+ |
{$IF defined(CompilerVersion) and (CompilerVersion >= 28)} |
5 |
+ |
{Delphi XE7 onwards}} |
6 |
+ |
{$define HASREQEX} |
7 |
+ |
{$IFEND} |
8 |
|
{$ENDIF} |
9 |
|
|
10 |
|
{Create and Drop a Database} |
21 |
|
{$IFDEF FPC} |
22 |
|
{$mode delphi} |
23 |
|
{$codepage utf8} |
24 |
+ |
{$define HASREQEX} |
25 |
|
{$ENDIF} |
26 |
|
|
27 |
|
interface |
85 |
|
Attachment.DropDatabase; |
86 |
|
|
87 |
|
writeln(OutFile,'Creating a Database using an SQL Statement'); |
88 |
< |
createSQL := Format('CREATE DATABASE ''%s'' USER ''%s'' PASSWORD ''%s'' DEFAULT CHARACTER SET %s', |
88 |
> |
createSQL := Format('create database ''%s'' USER ''%s'' PASSWORD ''%s'' DEFAULT CHARACTER SET %s', |
89 |
|
[Owner.GetNewDatabaseName, Owner.GetUserName, Owner.GetPassword, CharSet]); |
90 |
|
Attachment := FirebirdAPI.CreateDatabase(createSQL,SQLDialect); |
91 |
|
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_db_SQL_Dialect])); |
92 |
+ |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
93 |
+ |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
94 |
+ |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
95 |
+ |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
96 |
+ |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
97 |
+ |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
98 |
+ |
PrintDPB(Attachment.getDPB); |
99 |
+ |
|
100 |
+ |
{$IFDEF HASREQEX} |
101 |
+ |
{Demonstrate reconnect when database created with SQL Statement} |
102 |
+ |
try |
103 |
+ |
Attachment.Disconnect; |
104 |
+ |
Attachment.Connect; |
105 |
+ |
except on E:Exception do |
106 |
+ |
writeln(OutFile,'Error reconnecting to Database: ',E.Message); |
107 |
+ |
end; |
108 |
+ |
{$ENDIF} |
109 |
|
|
110 |
|
writeln(OutFile,'Dropping Database'); |
111 |
|
if Attachment <> nil then |
120 |
|
|
121 |
|
Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB); |
122 |
|
|
123 |
+ |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
124 |
+ |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
125 |
+ |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
126 |
+ |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
127 |
+ |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
128 |
+ |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
129 |
+ |
|
130 |
|
writeln(OutFile,'Dropping Database'); |
131 |
|
if Attachment <> nil then |
132 |
|
Attachment.DropDatabase; |
142 |
|
Exit; |
143 |
|
end; |
144 |
|
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version])); |
145 |
+ |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
146 |
+ |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
147 |
+ |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
148 |
+ |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
149 |
+ |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
150 |
+ |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
151 |
|
|
152 |
|
{Querying Database} |
153 |
|
DoQuery(Attachment); |