ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/udr/testsuite/udrlib/udr_test02.pas
(Generate patch)

Comparing ibx/branches/udr/udr/testsuite/udrlib/udr_test02.pas (file contents):
Revision 385 by tony, Mon Jan 10 10:08:03 2022 UTC vs.
Revision 386 by tony, Tue Jan 18 12:05:35 2022 UTC

# Line 68 | Line 68 | type
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;
# Line 90 | Line 139 | end;
139  
140   Initialization
141    FBRegisterUDRProcedure('test_proc',TMyTestProcedure);
142 +  FBRegisterUDRProcedure('error_proc',TMyErrorProc);
143  
144   end.
145  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines