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

Comparing ibx/branches/udr/udr/source/FBUDRController.pas (file contents):
Revision 371 by tony, Wed Jan 5 15:21:22 2022 UTC vs.
Revision 373 by tony, Thu Jan 6 14:14:57 2022 UTC

# Line 147 | Line 147 | type
147      function ReadConfigBool(Section, Ident: AnsiString; DefaultValue: boolean): boolean;
148    end;
149  
150 <   TFBUDRInputParams = class(TResults,IFBUDRInputParams);
151 <   TFBUDROutputParams = class(TSQLParams,IFBUDROutputData);
150 >   { TFBUDRInputParams }
151 >
152 >   TFBUDRInputParams = class(TResults,IFBUDRInputParams)
153 >   public
154 >    function ParamExists(Idx: AnsiString): boolean;
155 >    function ByName(Idx: AnsiString): ISQLData ; override;
156 >   end;
157 >
158 >   { TFBUDROutputParams }
159 >
160 >   TFBUDROutputParams = class(TSQLParams,IFBUDROutputData)
161 >   public
162 >     function ParamExists(Idx: AnsiString): boolean;
163 >     function ByName(Idx: AnsiString): ISQLParam ; override;
164 >   end;
165  
166     {TFBUDROutParamsSQLDA subclasses a TIBXINPUTSQLDA. TIBXINPUTSQLDA is defined
167      in support of executable statements and is usually used to prepare the
# Line 304 | Line 317 | type
317      FFieldNames: TStringList;
318      FFunction: TFBUDRFunctionClass;
319      FFBContext: IFBUDRExternalContext;
320 +    procedure SetController(AValue: TFBUDRController);
321      procedure UpdateFieldNames(att: IAttachment; aFunctionName: AnsiString);
322    public
323      constructor Create(aName: AnsiString; aFunction: TFBUDRFunctionClass);
324      destructor Destroy; override;
325 <    property Controller: TFBUDRController read FController write FController;
325 >    property Controller: TFBUDRController read FController write SetController;
326    public
327      {IUdrFunctionFactory}
328      procedure dispose(); override;
# Line 510 | Line 524 | type
524      FFBContext: IFBUDRExternalContext;
525      FInArgNames: TStringList;
526      FOutArgNames: TStringList;
527 +    procedure SetController(AValue: TFBUDRController);
528      procedure UpdateArgNames(att: IAttachment; aProcName: AnsiString);
529    public
530      constructor Create(aName: AnsiString; aProcedure: TFBUDRProcedureClass);
531      destructor Destroy; override;
532 <    property Controller: TFBUDRController read FController write FController;
532 >    property Controller: TFBUDRController read FController write SetController;
533    public
534      {IUdrProcedureFactory}
535      procedure dispose(); override;
# Line 624 | Line 639 | type
639      FTrigger: TFBUDRTriggerClass;
640      FFieldNames: TStringList;
641      FFBContext: IFBUDRExternalContext;
642 +    procedure SetController(AValue: TFBUDRController);
643      procedure UpdateFieldNames(att: IAttachment; aTableName: AnsiString);
644    public
645      constructor Create(aName: AnsiString; aTrigger: TFBUDRTriggerClass);
646      destructor Destroy; override;
647 <    property Controller: TFBUDRController read FController write FController;
647 >    property Controller: TFBUDRController read FController write SetController;
648    public
649      procedure dispose(); override;
650      procedure setup(status: Firebird.IStatus; context: Firebird.IExternalContext;
# Line 689 | Line 705 | resourcestring
705    SNoReturnValue = 'Function %s does not have a return value!';
706    STriggerIsNotImplemented = 'Trigger %s is not implemented';
707    STriggerNewAfter = 'New Field Values after trigger execution';
708 +  SUnknownFieldName = 'Unknown Field Name - %s';
709 +  SEof = 'No More Rows';
710  
711   function firebird_udr_plugin(status: Firebird.IStatus;
712    aTheirUnloadFlag: Firebird.BooleanPtr; udrPlugin: Firebird.IUdrPlugin
# Line 722 | Line 740 | begin
740    RegisterUDRFactory(aName,TFBUDRTriggerFactory.Create(aName,aTrigger));
741   end;
742  
743 + { TFBUDRInputParams }
744 +
745 + function TFBUDRInputParams.ParamExists(Idx: AnsiString): boolean;
746 + begin
747 +  Result := inherited ByName(Idx) <> nil;
748 + end;
749 +
750 + function TFBUDRInputParams.ByName(Idx: AnsiString): ISQLData;
751 + begin
752 +  Result := inherited ByName(Idx);
753 +  if Result = nil then
754 +    raise Exception.CreateFmt(SUnknownFieldName,[idx]);
755 + end;
756 +
757 + { TFBUDROutputParams }
758 +
759 + function TFBUDROutputParams.ParamExists(Idx: AnsiString): boolean;
760 + begin
761 +  Result := inherited ByName(Idx) <> nil;
762 + end;
763 +
764 + function TFBUDROutputParams.ByName(Idx: AnsiString): ISQLParam;
765 + begin
766 +  Result := inherited ByName(Idx);
767 +  if Result = nil then
768 +    raise Exception.CreateFmt(SUnknownFieldName,[idx]);
769 + end;
770 +
771   { TFBUDRTriggerNewValuesSQLDA }
772  
773   constructor TFBUDRTriggerNewValuesSQLDA.Create(context: IFBUDRExternalContext;
# Line 780 | Line 826 | begin
826      begin
827        Result := (FUDRProcedure as TFBUDRSelectProcedure).fetch(FOutputData);
828        if [loLogFetches,loDetails] <= FBUDRControllerOptions.LogOptions then
829 <        FUDRProcedure.FController.WriteToLog(SOutputParams,FOutputData);
829 >        if Result then
830 >          FUDRProcedure.FController.WriteToLog(SOutputParams,FOutputData)
831 >        else
832 >          FUDRProcedure.FController.WriteToLog(SEof);
833        FOutputDataSQLDA.Finalise;
834      end
835      else
# Line 937 | Line 986 | begin
986            InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FExternalContext,
987                                               metadata,
988                                               inMsg);
989 <        finally
989 >          SetFieldNames(InputParamsSQLDA);
990 >       finally
991            metadata.release;
992          end;
993        end;
# Line 999 | Line 1049 | begin
1049    end;
1050   end;
1051  
1052 + procedure TFBUDRTriggerFactory.SetController(AValue: TFBUDRController);
1053 + begin
1054 +  if FController = AValue then Exit;
1055 +  FController := AValue;
1056 +  FFBContext := TFBUDRExternalContext.Create(FController);
1057 + end;
1058 +
1059   constructor TFBUDRTriggerFactory.Create(aName: AnsiString;
1060    aTrigger: TFBUDRTriggerClass);
1061   begin
1062    inherited Create;
1063    FName := aName;
1064    FTrigger := aTrigger;
1008  FFBContext := TFBUDRExternalContext.Create(FController);
1065    FFieldNames := TStringList.Create;
1066   end;
1067  
# Line 1305 | Line 1361 | const
1361      ' FROM RDB$PROCEDURE_PARAMETERS PRM JOIN RDB$FIELDS FLD ON ' +
1362      ' PRM.RDB$FIELD_SOURCE = FLD.RDB$FIELD_NAME ' +
1363      'WHERE ' +
1364 <    '    PRM.RDB$PROCEDURE_NAME = ? AND ' +
1364 >    '    Trim(PRM.RDB$PROCEDURE_NAME) = ? AND ' +
1365      '    PRM.RDB$PARAMETER_TYPE = ? ' +
1366      'ORDER BY PRM.RDB$PARAMETER_NUMBER';
1367  
# Line 1334 | Line 1390 | begin
1390    UpdateFieldNames(1,FOutArgNames);
1391   end;
1392  
1393 + procedure TFBUDRProcedureFactory.SetController(AValue: TFBUDRController);
1394 + begin
1395 +  if FController = AValue then Exit;
1396 +  FController := AValue;
1397 +  FFBContext := TFBUDRExternalContext.Create(Controller);
1398 + end;
1399 +
1400   constructor TFBUDRProcedureFactory.Create(aName: AnsiString;
1401    aProcedure: TFBUDRProcedureClass);
1402   begin
1403    inherited Create;
1404    FName := aName;
1405    FProcedure := aProcedure;
1343  FFBContext := TFBUDRExternalContext.Create(Controller);
1406    FInArgNames := TStringList.Create;
1407    FOutArgNames := TStringList.Create;
1408   end;
# Line 1552 | Line 1614 | end;
1614  
1615   procedure TFBUDROutParamsSQLDA.AllocMessageBuffer(len: integer);
1616   begin
1617 +  FillChar(FBuffer^,len,0);
1618    FMessageBuffer := FBuffer;
1619    FMsgLength := len;
1620   end;
# Line 1777 | Line 1840 | begin
1840    end;
1841   end;
1842  
1843 + procedure TFBUDRFunctionFactory.SetController(AValue: TFBUDRController);
1844 + begin
1845 +  if FController = AValue then Exit;
1846 +  FController := AValue;
1847 +  FFBContext := TFBUDRExternalContext.Create(Controller);
1848 + end;
1849 +
1850   constructor TFBUDRFunctionFactory.Create(aName: AnsiString;
1851    aFunction: TFBUDRFunctionClass);
1852   begin
1853    inherited Create;
1854    FName := aName;
1855    FFunction := aFunction;
1786  FFBContext := TFBUDRExternalContext.Create(Controller);
1856    FFieldNames := TStringList.Create;
1857   end;
1858  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines