74 |
|
{initialize the emulator with the database connection} |
75 |
|
UDRPlugin.Attachment := Attachment; |
76 |
|
{Get the emulator wrapper for the row_count function, declared as MyRowCount} |
77 |
< |
MyRowCount := UDRPlugin.GetExternalFunction('MYROWCOUNT','','fbudrtests!row_count'); |
77 |
> |
MyRowCount := UDRPlugin.makeFunction('MYROWCOUNT','','fbudrtests!row_count'); |
78 |
|
try |
79 |
|
writeln(OutFile,'Row Count for Employee'); |
80 |
|
{set the input parameter to the EMPLOYEE table} |
83 |
|
ParamInfo(MyRowCount.InputParams); |
84 |
|
Transaction := Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit); |
85 |
|
{invoke the function and print the result} |
86 |
< |
writeln('Employee Row Count = ',MyRowCount.Execute(Transaction).AsInteger); |
86 |
> |
writeln(Outfile,'Employee Row Count = ',MyRowCount.Execute(Transaction).AsInteger); |
87 |
|
writeln(OutFile); |
88 |
|
|
89 |
|
{Try again with the DEPARTMENT table} |
90 |
|
MyRowCount.InputParams[0].AsString := 'DEPARTMENT'; |
91 |
|
ParamInfo(MyRowCount.InputParams); |
92 |
< |
writeln('Dept Row Count = ',MyRowCount.Execute(Transaction).AsInteger); |
92 |
> |
writeln(Outfile,'Dept Row Count = ',MyRowCount.Execute(Transaction).AsInteger); |
93 |
|
writeln(OutFile); |
94 |
|
|
95 |
|
{And again but demonstrate exception handling by using an invalid table name} |
97 |
|
try |
98 |
|
ParamInfo(MyRowCount.InputParams); |
99 |
|
Rows := MyRowCount.Execute(Transaction).AsInteger; |
100 |
< |
writeln('Dept Row Count = ',Rows); |
100 |
> |
writeln(Outfile,'Dept Row Count = ',Rows); |
101 |
|
writeln(OutFile); |
102 |
|
except on E: Exception do |
103 |
|
writeln(Outfile,'Expected exception: ',E.Message); |
108 |
|
|
109 |
|
writeln(OutFile); |
110 |
|
{Now call the external version with an error} |
111 |
< |
MyRowCount := UDRPlugin.GetExternalFunction('BADROWCOUNT','','fbudrtests!bad_row_count'); |
111 |
> |
MyRowCount := UDRPlugin.makeFunction('BADROWCOUNT','','fbudrtests!bad_row_count'); |
112 |
|
try |
113 |
|
try |
114 |
|
writeln(OutFile,'Row Count for Employee'); |
115 |
|
MyRowCount.InputParams[0].AsString := 'EMPLOYEE'; |
116 |
|
ParamInfo(MyRowCount.InputParams); |
117 |
|
Transaction := Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit); |
118 |
< |
writeln('Employee Row Count = ',MyRowCount.Execute(Transaction).AsInteger); |
118 |
> |
writeln(Outfile,'Employee Row Count = ',MyRowCount.Execute(Transaction).AsInteger); |
119 |
|
except on E: Exception do |
120 |
|
writeln(Outfile,'Expected exception: ',E.Message); |
121 |
|
end; |
132 |
|
Transaction: ITransaction; |
133 |
|
begin |
134 |
|
UDRPlugin.Attachment := Attachment; |
135 |
< |
ReturnInfo := UDRPlugin.GetExternalFunction('RETURNINFO','','fbudrtests!return_info!Hello World'); |
135 |
> |
ReturnInfo := UDRPlugin.makeFunction('RETURNINFO','','fbudrtests!return_info!Hello World'); |
136 |
|
try |
137 |
|
Transaction := Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit); |
138 |
|
writeln(OutFile,'Info returned = ',ReturnInfo.Execute(Transaction).AsString); |