68 |
|
OutputData: IFBUDROutputData); override; |
69 |
|
end; |
70 |
|
|
71 |
+ |
{TMyErrorProc is intended to test out error handling for various error conditions} |
72 |
+ |
|
73 |
+ |
{ |
74 |
+ |
Create or Alter procedure MyErrorProc ( |
75 |
+ |
ErrorCase Smallint) |
76 |
+ |
external name 'fbudrtests!error_proc' |
77 |
+ |
engine udr; |
78 |
+ |
} |
79 |
+ |
|
80 |
+ |
TMyErrorProc = class(TFBUDRExecuteProcedure) |
81 |
+ |
public |
82 |
+ |
procedure Execute(context: IFBUDRExternalContext; |
83 |
+ |
ProcMetadata: IFBUDRProcMetadata; |
84 |
+ |
InputParams: IFBUDRInputParams; |
85 |
+ |
OutputData: IFBUDROutputData); override; |
86 |
+ |
end; |
87 |
+ |
|
88 |
|
implementation |
89 |
|
|
90 |
+ |
{ TMyErrorProc } |
91 |
+ |
|
92 |
+ |
procedure TMyErrorProc.Execute(context: IFBUDRExternalContext; |
93 |
+ |
ProcMetadata: IFBUDRProcMetadata; InputParams: IFBUDRInputParams; |
94 |
+ |
OutputData: IFBUDROutputData); |
95 |
+ |
var aResult: integer; |
96 |
+ |
begin |
97 |
+ |
with context do |
98 |
+ |
case InputParams.ByName('ErrorCase').AsInteger of |
99 |
+ |
0: |
100 |
+ |
{DDL error - duplicate table name} |
101 |
+ |
begin |
102 |
+ |
GetAttachment.ExecImmediate([isc_tpb_write, isc_tpb_nowait, isc_tpb_read_committed], |
103 |
+ |
'Create Global Temporary Table TestMe(EMP_NO Integer)'); |
104 |
+ |
GetAttachment.ExecImmediate([isc_tpb_write, isc_tpb_nowait, isc_tpb_read_committed], |
105 |
+ |
'Create Global Temporary Table TestMe(EMP_NO Integer)'); |
106 |
+ |
end; |
107 |
+ |
|
108 |
+ |
1: |
109 |
+ |
{General Exception handling} |
110 |
+ |
raise Exception.Create('You have a bug'); |
111 |
+ |
|
112 |
+ |
2: |
113 |
+ |
{arithmetic exception - divide by zero} |
114 |
+ |
begin |
115 |
+ |
aResult := 0; |
116 |
+ |
aResult := Round(100/aResult); |
117 |
+ |
end; |
118 |
+ |
|
119 |
+ |
end; |
120 |
+ |
end; |
121 |
+ |
|
122 |
|
{ TMyTestProcedure } |
123 |
|
|
124 |
|
procedure TMyTestProcedure.Execute(context: IFBUDRExternalContext; |
139 |
|
|
140 |
|
Initialization |
141 |
|
FBRegisterUDRProcedure('test_proc',TMyTestProcedure); |
142 |
+ |
FBRegisterUDRProcedure('error_proc',TMyErrorProc); |
143 |
|
|
144 |
|
end. |
145 |
|
|