ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/examples/UserManual/testbed/myudrtestbed.lpr
Revision: 381
Committed: Sat Jan 15 00:06:22 2022 UTC (3 days, 16 hours ago) by tony
File size: 2315 byte(s)
Log Message:
Release Candidate 1
Line File contents
1 program myudrtestbed;
2
3 {$mode delphi}
4 {$codepage UTF8}
5 {$interfaces COM}
6
7 uses Classes, FBUDRController, FBUdrPlugin, IB, udr_myrowcount;
8
9 procedure TestRowCount(UDRPlugin: TFBUdrPluginEmulator);
10 var MyRowCount: TExternalFunctionWrapper;
11 Transaction: ITransaction;
12 Rows: integer;
13 begin
14 {Get the emulator wrapper for the row_count function, declared as MyRowCount}
15 MyRowCount := UDRPlugin.makeFunction('MYROWCOUNT', {Name of Function in database - case sensitive}
16 '', {package name is empty}
17 'myudrlibrary!row_count' {entry point}
18 );
19 try
20 writeln('Row Count for Employee');
21 {set the input parameter to the EMPLOYEE table}
22 MyRowCount.InputParams[0].AsString := 'EMPLOYEE';
23
24 Transaction := UDRPlugin.Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit);
25 {invoke the function and print the result}
26 writeln('Employee Row Count = ',MyRowCount.Execute(Transaction).AsInteger);
27 writeln;
28 finally
29 MyRowCount.Free
30 end;
31 end;
32
33 procedure RunTest;
34 var Attachment: IAttachment;
35 DPB: IDPB;
36 UDRPlugin: TFBUdrPluginEmulator;
37 begin
38 {Open a connection with the example employee database. Amend database parameters
39 as needed.}
40 DPB := FirebirdAPI.AllocateDPB;
41 DPB.Add(isc_dpb_user_name).setAsString('SYSDBA');
42 DPB.Add(isc_dpb_password).setAsString('masterkey');
43 DPB.Add(isc_dpb_lc_ctype).setAsString('UTF8');
44 DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(3);
45 Attachment := FirebirdAPI.OpenDatabase('localhost:employee',DPB);
46 try
47 UDRPlugin := TFBUdrPluginEmulator.Create(FBUDRControllerOptions.ModuleName);
48 try
49 {initialize the emulator with the database connection}
50 UDRPlugin.Attachment := Attachment;
51 TestRowCount(UDRPlugin);
52 finally
53 UDRPlugin.Free;
54 end;
55 finally
56 Attachment.Disconnect(true);
57 end;
58 end;
59
60 begin
61 with FBUDRControllerOptions do
62 begin
63 ModuleName := 'myudrlibrary';
64 AllowConfigFileOverrides := true;
65 LogFileNameTemplate := '$LOGDIR$MODULE.log';
66 LogOptions := [loLogFunctions, loLogProcedures, loLogTriggers, loDetails];
67 end;
68 RunTest;
69 {$IFDEF WINDOWS}
70 readln; {force console window to stay open}
71 {$ENDIF}
72 end.
73

Properties

Name Value
svn:eol-style native