244 |
|
private |
245 |
|
FController: TFBUDRController; |
246 |
|
FName: AnsiString; |
247 |
– |
FExternalContext: IFBUDRExternalContext; |
247 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
248 |
|
FFieldNames: TStrings; |
249 |
|
procedure SetFieldNames(SQLDA: TFBUDRInParamsSQLDA); |
250 |
|
public |
251 |
|
constructor Create(aController: TFBUDRController; |
252 |
|
aName: AnsiString; |
254 |
– |
context: IFBUDRExternalContext; |
253 |
|
routineMetadata: IFBUDRRoutineMetadata; |
254 |
|
aFieldNames: TStrings); |
255 |
|
public |
257 |
|
|
258 |
|
{Override getCharSet when the function returns strings in a different charset |
259 |
|
to that used by the database connection.} |
260 |
< |
function getCharSet(context: IFBUDRExternalContext): AnsiString; overload; virtual; |
260 |
> |
function getCharSet(context: IFBUDRExternalContext): AnsiString; overload; virtual; |
261 |
|
|
262 |
|
{Execute must be overridden by each subclass in order to define a new UDR |
263 |
|
function. The function returns its output value in a variant. The value |
281 |
|
function factory is first used and may be used to initialise any class vars |
282 |
|
used by the Execute function. This is normally only required with stateful |
283 |
|
functions.} |
284 |
< |
class procedure setup(context: IFBUDRExternalContext; |
284 |
> |
class procedure setup(context: IFBUDRExternalContext; |
285 |
|
metadata: IFBUDRRoutineMetadata; |
286 |
|
inBuilder: IFBUDRMetadataBuilder; |
287 |
|
outBuilder: IFBUDRMetadataBuilder); virtual; |
288 |
< |
property Name: AnsiString read FName; |
289 |
< |
public |
288 |
> |
property Name: AnsiString read FName; |
289 |
> |
property Controller: TFBUDRController read FController; |
290 |
> |
public |
291 |
|
{IExternalFunction} |
292 |
|
procedure dispose(); override; |
293 |
|
procedure getCharSet(status: Firebird.IStatus; context: Firebird.IExternalContext; |
315 |
|
FName: AnsiString; |
316 |
|
FFieldNames: TStringList; |
317 |
|
FFunction: TFBUDRFunctionClass; |
319 |
– |
FFBContext: IFBUDRExternalContext; |
318 |
|
procedure SetController(AValue: TFBUDRController); |
319 |
|
procedure UpdateFieldNames(att: IAttachment; aFunctionName: AnsiString); |
320 |
|
public |
343 |
|
private |
344 |
|
FController: TFBUDRController; |
345 |
|
FName: AnsiString; |
348 |
– |
FExternalContext: IFBUDRExternalContext; |
346 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
347 |
|
FRefCount: integer; |
348 |
|
protected |
352 |
|
public |
353 |
|
constructor Create(aController: TFBUDRController; |
354 |
|
aName: AnsiString; |
358 |
– |
context: IFBUDRExternalContext; |
355 |
|
routineMetadata: IFBUDRRoutineMetadata; |
356 |
|
aInArgNames, aOutArgNames: TStrings); |
357 |
|
public |
371 |
|
inBuilder: IFBUDRMetadataBuilder; |
372 |
|
outBuilder: IFBUDRMetadataBuilder); virtual; |
373 |
|
property Name: AnsiString read FName; |
374 |
+ |
property Controller: TFBUDRController read FController; |
375 |
|
public |
376 |
|
{IExternalProcedure} |
377 |
|
procedure dispose(); override; |
518 |
|
FController: TFBUDRController; |
519 |
|
FName: AnsiString; |
520 |
|
FProcedure: TFBUDRProcedureClass; |
524 |
– |
FFBContext: IFBUDRExternalContext; |
521 |
|
FInArgNames: TStringList; |
522 |
|
FOutArgNames: TStringList; |
523 |
|
procedure SetController(AValue: TFBUDRController); |
551 |
|
private |
552 |
|
FController: TFBUDRController; |
553 |
|
FName: AnsiString; |
558 |
– |
FExternalContext: IFBUDRExternalContext; |
554 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
555 |
|
FFieldNames: TStrings; |
556 |
|
procedure SetFieldNames(SQLDA: TSQLDataArea); |
557 |
|
public |
558 |
|
constructor Create(aController: TFBUDRController; |
559 |
|
aName: AnsiString; |
565 |
– |
context: IFBUDRExternalContext; |
560 |
|
routineMetadata: IFBUDRRoutineMetadata; |
561 |
|
aFieldNames: TStrings); |
562 |
|
public |
607 |
|
fieldsBuilder: IFBUDRMetadataBuilder); virtual; |
608 |
|
|
609 |
|
property Name: AnsiString read FName; |
610 |
+ |
property Controller: TFBUDRController read FController; |
611 |
|
public |
612 |
|
{IExternalTrigger} |
613 |
|
procedure dispose(); override; |
633 |
|
FName: AnsiString; |
634 |
|
FTrigger: TFBUDRTriggerClass; |
635 |
|
FFieldNames: TStringList; |
641 |
– |
FFBContext: IFBUDRExternalContext; |
636 |
|
procedure SetController(AValue: TFBUDRController); |
637 |
|
procedure UpdateFieldNames(att: IAttachment; aTableName: AnsiString); |
638 |
|
public |
683 |
|
sFuncCreated = 'Function %s created'; |
684 |
|
SInputParams = 'Input Parameters'; |
685 |
|
SOutputParams = 'Output Parameters'; |
686 |
+ |
SOutputData = 'Output Parameters with data'; |
687 |
|
SFuncDispose = 'Function %s: dispose called'; |
688 |
|
SFuncCharset = 'GetCharSet for Function %s charset name = "%s"'; |
689 |
|
SFuncExecute = 'Execute Function '; |
822 |
|
Result := (FUDRProcedure as TFBUDRSelectProcedure).fetch(FOutputData); |
823 |
|
if [loLogFetches,loDetails] <= FBUDRControllerOptions.LogOptions then |
824 |
|
if Result then |
825 |
< |
FUDRProcedure.FController.WriteToLog(SOutputParams,FOutputData) |
825 |
> |
FUDRProcedure.FController.WriteToLog(SOutputData,FOutputData) |
826 |
|
else |
827 |
|
FUDRProcedure.FController.WriteToLog(SEof); |
828 |
|
FOutputDataSQLDA.Finalise; |
849 |
|
if FOutputDataSQLDA <> nil then |
850 |
|
begin |
851 |
|
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
852 |
< |
FUDRProcedure.FController.WriteToLog(SOutputParams,FOutputData); |
852 |
> |
FUDRProcedure.FController.WriteToLog(SOutputData,FOutputData); |
853 |
|
FOutputDataSQLDA.Finalise; {copy output row to outMsg} |
854 |
|
Result := not FFetchCalled; |
855 |
|
FFetchCalled := true; |
870 |
|
InputParamsSQLDA: TFBUDRInParamsSQLDA; |
871 |
|
InputParams: IFBUDRInputParams; |
872 |
|
metadata: Firebird.IMessageMetadata; |
873 |
+ |
FBContext: IFBUDRExternalContext; |
874 |
|
begin |
875 |
|
InputParams := nil; |
876 |
|
InputParamsSQLDA := nil; |
882 |
|
FBUDRError(ibxeNoProcMetadata,[nil]) |
883 |
|
else |
884 |
|
begin |
885 |
< |
with (FExternalContext as TFBUDRExternalContext) do |
886 |
< |
begin |
887 |
< |
Assign(context); |
892 |
< |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
893 |
< |
FController.WriteToLog(AsText); |
894 |
< |
end; |
885 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
886 |
> |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
887 |
> |
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
888 |
|
|
889 |
|
if FRoutineMetadata.HasInputMetadata then |
890 |
|
begin |
891 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getInputMetadata; |
892 |
|
try |
893 |
< |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FExternalContext, |
893 |
> |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
894 |
|
metadata, |
895 |
|
inMsg); |
896 |
|
SetFieldNames(InputParamsSQLDA); |
912 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
913 |
|
|
914 |
|
try |
915 |
< |
Result := TFBUDRSingletonRow.Create(self, FExternalContext, FOutArgNames, |
915 |
> |
Result := TFBUDRSingletonRow.Create(self, FBContext, FOutArgNames, |
916 |
|
metadata, |
917 |
|
outMsg); |
918 |
|
|
921 |
|
metadata.release; |
922 |
|
end; |
923 |
|
|
924 |
< |
Execute(FExternalContext,aProcMetadata,InputParams, |
924 |
> |
Execute(FBContext,aProcMetadata,InputParams, |
925 |
|
(Result as TFBUDRSingletonRow).OutputData); |
926 |
|
finally |
927 |
|
InputParams := nil; |
954 |
|
InputParamsSQLDA: TFBUDRInParamsSQLDA; |
955 |
|
InputParams: IFBUDRInputParams; |
956 |
|
metadata: Firebird.IMessageMetadata; |
957 |
+ |
FBContext: IFBUDRExternalContext; |
958 |
|
begin |
959 |
|
try |
960 |
|
if loLogProcedures in FBUDRControllerOptions.LogOptions then |
966 |
|
FBUDRError(ibxeNoProcMetadata,[nil]) |
967 |
|
else |
968 |
|
begin |
969 |
< |
with (FExternalContext as TFBUDRExternalContext) do |
970 |
< |
begin |
971 |
< |
Assign(context); |
978 |
< |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
979 |
< |
FController.WriteToLog(AsText); |
980 |
< |
end; |
969 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
970 |
> |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
971 |
> |
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
972 |
|
|
973 |
|
if FRoutineMetadata.HasInputMetadata then |
974 |
|
begin |
975 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getInputMetadata; |
976 |
|
try |
977 |
< |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FExternalContext, |
977 |
> |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
978 |
|
metadata, |
979 |
|
inMsg); |
980 |
|
SetFieldNames(InputParamsSQLDA); |
996 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
997 |
|
|
998 |
|
try |
999 |
< |
open(FExternalContext,aProcMetadata,InputParams); |
1000 |
< |
Result := TFBUDRResultsCursor.Create(self, FExternalContext, |
999 |
> |
open(FBContext,aProcMetadata,InputParams); |
1000 |
> |
Result := TFBUDRResultsCursor.Create(self, FBContext, |
1001 |
|
FOutArgNames, |
1002 |
|
metadata, |
1003 |
|
outMsg); |
1044 |
|
begin |
1045 |
|
if FController = AValue then Exit; |
1046 |
|
FController := AValue; |
1056 |
– |
FFBContext := TFBUDRExternalContext.Create(FController); |
1047 |
|
end; |
1048 |
|
|
1049 |
|
constructor TFBUDRTriggerFactory.Create(aName: AnsiString; |
1072 |
|
fieldsBuilder: Firebird.IMetadataBuilder); |
1073 |
|
var FBRoutineMetadata: IFBUDRRoutineMetadata; |
1074 |
|
FBFieldsBuilder: IFBUDRMetadataBuilder; |
1075 |
+ |
FBContext: IFBUDRExternalContext; |
1076 |
|
begin |
1077 |
|
FBFieldsBuilder := nil; |
1078 |
|
try |
1079 |
|
if loLogTriggers in FBUDRControllerOptions.LogOptions then |
1080 |
|
FController.WriteToLog(SSetupTrigger + FName); |
1081 |
|
|
1082 |
< |
(FFBContext as TFBUDRExternalContext).Assign(context); |
1083 |
< |
FController.StartJournaling(FFBContext); |
1082 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1083 |
> |
FController.StartJournaling(FBContext); |
1084 |
|
|
1085 |
< |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FFBContext,metadata); |
1085 |
> |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1086 |
|
|
1087 |
|
if fieldsBuilder <> nil then |
1088 |
< |
FBFieldsBuilder := TFBUDRMetadataBuilder.Create(FFBContext,fieldsBuilder); |
1089 |
< |
TFBUDRTrigger.setup(FFBContext,FBRoutineMetadata,FBFieldsBuilder) |
1088 |
> |
FBFieldsBuilder := TFBUDRMetadataBuilder.Create(FBContext,fieldsBuilder); |
1089 |
> |
if [loLogTriggers, loDetails] <= FBUDRControllerOptions.LogOptions then |
1090 |
> |
FController.WriteToLog(SRoutineMetadata + LineEnding + (FBRoutineMetadata as TFBUDRRoutineMetadata).AsText); |
1091 |
> |
TFBUDRTrigger.setup(FBContext,FBRoutineMetadata,FBFieldsBuilder) |
1092 |
|
except on E: Exception do |
1093 |
|
FController.FBSetStatusFromException(E,status); |
1094 |
|
end; |
1098 |
|
context: Firebird.IExternalContext; metadata: Firebird.IRoutineMetadata |
1099 |
|
): Firebird.IExternalTrigger; |
1100 |
|
var FBRoutineMetadata: IFBUDRRoutineMetadata; |
1101 |
+ |
FBContext: IFBUDRExternalContext; |
1102 |
|
begin |
1103 |
|
try |
1104 |
< |
(FFBContext as TFBUDRExternalContext).Assign(context); |
1105 |
< |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FFBContext,metadata); |
1104 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1105 |
> |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1106 |
|
{Now get the Field Names} |
1107 |
< |
UpdateFieldNames(FFBContext.GetAttachment,FBRoutineMetadata.getTriggerTable); |
1108 |
< |
Result := FTrigger.Create(FController,FName,FFBContext,FBRoutineMetadata,FFieldNames); |
1107 |
> |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getTriggerTable); |
1108 |
> |
Result := FTrigger.Create(FController,FName,FBRoutineMetadata,FFieldNames); |
1109 |
|
except on E: Exception do |
1110 |
|
FController.FBSetStatusFromException(E,status); |
1111 |
|
end; |
1122 |
|
end; |
1123 |
|
|
1124 |
|
constructor TFBUDRTrigger.Create(aController: TFBUDRController; |
1125 |
< |
aName: AnsiString; context: IFBUDRExternalContext; |
1126 |
< |
routineMetadata: IFBUDRRoutineMetadata; aFieldNames: TStrings); |
1125 |
> |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata; |
1126 |
> |
aFieldNames: TStrings); |
1127 |
|
begin |
1128 |
|
inherited Create; |
1129 |
|
FName := aName; |
1130 |
|
FController := aController; |
1137 |
– |
FExternalContext := context; |
1131 |
|
FRoutineMetaData := routineMetadata; |
1132 |
|
FFieldNames := aFieldNames; |
1133 |
|
end; |
1174 |
|
procedure TFBUDRTrigger.getCharSet(status: Firebird.IStatus; |
1175 |
|
context: Firebird.IExternalContext; name: PAnsiChar; nameSize: Cardinal); |
1176 |
|
var charset: AnsiString; |
1177 |
+ |
FBContext: IFBUDRExternalContext; |
1178 |
|
begin |
1179 |
|
try |
1180 |
< |
(FExternalContext as TFBUDRExternalContext).Assign(context); |
1181 |
< |
charset := getCharSet(FExternalContext); |
1180 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1181 |
> |
charset := getCharSet(FBContext); |
1182 |
|
if charset <> '' then |
1183 |
|
begin |
1184 |
|
StrPLCopy(name,charset,nameSize); |
1201 |
|
NewParams: IFBUDRInputParams; |
1202 |
|
NewWritableParams: IFBUDROutputData; |
1203 |
|
TriggerAction: TFBUDRTriggerAction; |
1204 |
+ |
FBContext: IFBUDRExternalContext; |
1205 |
|
|
1206 |
|
procedure SetUpOldParams; |
1207 |
|
var metadata: Firebird.IMessageMetadata; |
1208 |
|
begin |
1209 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getTriggerMetadata; |
1210 |
|
try |
1211 |
< |
OldParamsSQLDA := TFBUDRInParamsSQLDA.Create(FExternalContext, |
1211 |
> |
OldParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
1212 |
|
metadata, |
1213 |
|
oldMsg); |
1214 |
|
SetFieldNames(OldParamsSQLDA); |
1227 |
|
begin |
1228 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getTriggerMetadata; |
1229 |
|
try |
1230 |
< |
NewParamsSQLDA := TFBUDRInParamsSQLDA.Create(FExternalContext, |
1230 |
> |
NewParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
1231 |
|
metadata, |
1232 |
|
newMsg); |
1233 |
|
SetFieldNames(NewParamsSQLDA); |
1246 |
|
begin |
1247 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getTriggerMetadata; |
1248 |
|
try |
1249 |
< |
WritableParamsSQLDA := TFBUDRTriggerNewValuesSQLDA.Create(FExternalContext, |
1249 |
> |
WritableParamsSQLDA := TFBUDRTriggerNewValuesSQLDA.Create(FBContext, |
1250 |
|
metadata, |
1251 |
|
newMsg); |
1252 |
|
SetFieldNames(WritableParamsSQLDA); |
1275 |
|
FBUDRError(ibxeNoTriggerMetadata,[nil]) |
1276 |
|
else |
1277 |
|
begin |
1278 |
< |
(FExternalContext as TFBUDRExternalContext).Assign(context); |
1278 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1279 |
|
|
1280 |
|
with Firebird.IExternalTrigger do |
1281 |
|
case action of |
1312 |
|
if TriggerAction in [taInsert,taUpdate] then |
1313 |
|
SetupWritableNewParams; |
1314 |
|
end; |
1315 |
< |
BeforeTrigger(FExternalContext,aTriggerMetadata,TriggerAction,OldParams,NewWritableParams); |
1315 |
> |
BeforeTrigger(FBContext,aTriggerMetadata,TriggerAction,OldParams,NewWritableParams); |
1316 |
|
WritableParamsSQLDA.Finalise; |
1317 |
|
if [loLogTriggers,loDetails] <= FBUDRControllerOptions.LogOptions then |
1318 |
|
FController.WriteToLog(STriggerNewAfter,NewWritableParams); |
1325 |
|
SetUpOldParams; |
1326 |
|
if TriggerAction in [taInsert,taUpdate] then |
1327 |
|
SetupNewParams; |
1328 |
< |
AfterTrigger(FExternalContext,aTriggerMetadata,TriggerAction,OldParams,NewParams); |
1328 |
> |
AfterTrigger(FBContext,aTriggerMetadata,TriggerAction,OldParams,NewParams); |
1329 |
|
end; |
1330 |
|
end; |
1331 |
|
ttDatabase: |
1332 |
|
begin |
1333 |
< |
DatabaseTrigger(FExternalContext,aTriggerMetadata); |
1333 |
> |
DatabaseTrigger(FBContext,aTriggerMetadata); |
1334 |
|
end; |
1335 |
|
end; |
1336 |
|
finally |
1389 |
|
begin |
1390 |
|
if FController = AValue then Exit; |
1391 |
|
FController := AValue; |
1397 |
– |
FFBContext := TFBUDRExternalContext.Create(Controller); |
1392 |
|
end; |
1393 |
|
|
1394 |
|
constructor TFBUDRProcedureFactory.Create(aName: AnsiString; |
1421 |
|
var FBRoutineMetadata: IFBUDRRoutineMetadata; |
1422 |
|
FBInBuilder: IFBUDRMetadataBuilder; |
1423 |
|
FBOutBuilder: IFBUDRMetadataBuilder; |
1424 |
+ |
FBContext: IFBUDRExternalContext; |
1425 |
|
begin |
1426 |
|
try |
1427 |
|
if loLogProcedures in FBUDRControllerOptions.LogOptions then |
1429 |
|
|
1430 |
|
FBInBuilder := nil; |
1431 |
|
FBOutBuilder := nil; |
1432 |
< |
(FFBContext as TFBUDRExternalContext).Assign(context); |
1433 |
< |
FController.StartJournaling(FFBContext); |
1432 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1433 |
> |
FController.StartJournaling(FBContext); |
1434 |
|
|
1435 |
< |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FFBContext,metadata); |
1435 |
> |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1436 |
|
if inBuilder <> nil then |
1437 |
< |
FBInBuilder := TFBUDRMetadataBuilder.Create(FFBContext,inBuilder); |
1437 |
> |
FBInBuilder := TFBUDRMetadataBuilder.Create(FBContext,inBuilder); |
1438 |
|
if outBuilder <> nil then |
1439 |
< |
FBOutBuilder := TFBUDRMetadataBuilder.Create(FFBContext,outBuilder); |
1440 |
< |
TFBUDRProcedure.setup(FFBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder) |
1439 |
> |
FBOutBuilder := TFBUDRMetadataBuilder.Create(FBContext,outBuilder); |
1440 |
> |
if [loLogProcedures, loDetails] <= FBUDRControllerOptions.LogOptions then |
1441 |
> |
FController.WriteToLog(SRoutineMetadata + LineEnding + (FBRoutineMetadata as TFBUDRRoutineMetadata).AsText); |
1442 |
> |
TFBUDRProcedure.setup(FBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder) |
1443 |
|
except on E: Exception do |
1444 |
|
FController.FBSetStatusFromException(E,status); |
1445 |
|
end; |
1449 |
|
context: Firebird.IExternalContext; metadata: Firebird.IRoutineMetadata |
1450 |
|
): IExternalProcedure; |
1451 |
|
var FBRoutineMetadata: IFBUDRRoutineMetadata; |
1452 |
+ |
FBContext: IFBUDRExternalContext; |
1453 |
|
begin |
1454 |
|
try |
1455 |
< |
(FFBContext as TFBUDRExternalContext).Assign(context); |
1456 |
< |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FFBContext,metadata); |
1455 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1456 |
> |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1457 |
|
{Now get the Field Names} |
1458 |
< |
UpdateArgNames(FFBContext.GetAttachment,FBRoutineMetadata.getName); |
1459 |
< |
Result := FProcedure.Create(FController,FName,FFBContext,FBRoutineMetadata, |
1458 |
> |
UpdateArgNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1459 |
> |
Result := FProcedure.Create(FController,FName,FBRoutineMetadata, |
1460 |
|
FInArgNames,FOutArgNames); |
1461 |
|
except on E: Exception do |
1462 |
|
FController.FBSetStatusFromException(E,status); |
1522 |
|
end; |
1523 |
|
|
1524 |
|
constructor TFBUDRProcedure.Create(aController: TFBUDRController; |
1525 |
< |
aName: AnsiString; context: IFBUDRExternalContext; |
1526 |
< |
routineMetadata: IFBUDRRoutineMetadata; aInArgNames, aOutArgNames: TStrings); |
1525 |
> |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata; aInArgNames, |
1526 |
> |
aOutArgNames: TStrings); |
1527 |
|
begin |
1528 |
|
inherited Create; |
1529 |
|
FController := aController; |
1530 |
|
FName := aName; |
1531 |
|
FRefCount := 1; |
1534 |
– |
FExternalContext := context; |
1532 |
|
FRoutineMetaData := routineMetadata; |
1533 |
|
FInArgNames := aInArgNames; |
1534 |
|
FOutArgNames := aOutArgNames; |
1558 |
|
procedure TFBUDRProcedure.getCharSet(status: Firebird.IStatus; |
1559 |
|
context: Firebird.IExternalContext; name: PAnsiChar; nameSize: Cardinal); |
1560 |
|
var charset: AnsiString; |
1561 |
+ |
FBContext: IFBUDRExternalContext; |
1562 |
|
begin |
1563 |
|
try |
1564 |
< |
(FExternalContext as TFBUDRExternalContext).Assign(context); |
1565 |
< |
charset := getCharSet(FExternalContext); |
1564 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1565 |
> |
charset := getCharSet(FBContext); |
1566 |
|
if charset <> '' then |
1567 |
|
begin |
1568 |
|
StrPLCopy(name,charset,nameSize); |
1664 |
|
end; |
1665 |
|
|
1666 |
|
constructor TFBUDRFunction.Create(aController: TFBUDRController; |
1667 |
< |
aName: AnsiString; context: IFBUDRExternalContext; |
1668 |
< |
routineMetadata: IFBUDRRoutineMetadata; aFieldNames: TStrings); |
1667 |
> |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata; |
1668 |
> |
aFieldNames: TStrings); |
1669 |
|
begin |
1670 |
|
inherited Create; |
1671 |
|
FController := aController; |
1672 |
|
FName := aName; |
1673 |
|
FFieldNames := aFieldNames; |
1676 |
– |
FExternalContext := context; |
1674 |
|
FRoutineMetaData := routineMetadata; |
1675 |
|
if loLogFunctions in FBUDRControllerOptions.LogOptions then |
1676 |
|
begin |
1717 |
|
procedure TFBUDRFunction.getCharSet(status: Firebird.IStatus; |
1718 |
|
context: Firebird.IExternalContext; name: PAnsiChar; nameSize: Cardinal); |
1719 |
|
var charset: AnsiString; |
1720 |
+ |
FBContext: IFBUDRExternalContext; |
1721 |
|
begin |
1722 |
|
try |
1723 |
< |
(FExternalContext as TFBUDRExternalContext).Assign(context); |
1724 |
< |
charset := getCharSet(FExternalContext); |
1723 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1724 |
> |
charset := getCharSet(FBContext); |
1725 |
|
if charset <> '' then |
1726 |
|
begin |
1727 |
|
StrPLCopy(name,charset,nameSize); |
1741 |
|
InputParams: IFBUDRInputParams; |
1742 |
|
OutputData: IFBUDROutputData; |
1743 |
|
metadata: Firebird.IMessageMetadata; |
1744 |
+ |
FBContext: IFBUDRExternalContext; |
1745 |
|
begin |
1746 |
|
try |
1747 |
|
if loLogFunctions in FBUDRControllerOptions.LogOptions then |
1755 |
|
FBUDRError(ibxeNoProcMetadata,[nil]) |
1756 |
|
else |
1757 |
|
begin |
1758 |
< |
with FExternalContext as TFBUDRExternalContext do |
1759 |
< |
begin |
1760 |
< |
Assign(context); |
1762 |
< |
if [loLogFunctions,loDetails] <= FBUDRControllerOptions.LogOptions then |
1763 |
< |
FController.WriteToLog(AsText); |
1764 |
< |
end; |
1758 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1759 |
> |
if [loLogFunctions,loDetails] <= FBUDRControllerOptions.LogOptions then |
1760 |
> |
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
1761 |
|
|
1762 |
|
try |
1763 |
|
if FRoutineMetadata.HasInputMetadata then |
1764 |
|
begin |
1765 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getInputMetadata; |
1766 |
|
try |
1767 |
< |
InParamsSQLDA := TFBUDRInParamsSQLDA.Create(FExternalContext, |
1767 |
> |
InParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
1768 |
|
metadata, |
1769 |
|
inMsg); |
1770 |
|
SetFieldNames(InParamsSQLDA); |
1781 |
|
begin |
1782 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
1783 |
|
try |
1784 |
< |
OutParamsSQLDA := TFBUDROutParamsSQLDA.Create(FExternalContext, |
1784 |
> |
OutParamsSQLDA := TFBUDROutParamsSQLDA.Create(FBContext, |
1785 |
|
metadata, |
1786 |
|
outMsg); |
1787 |
|
finally |
1792 |
|
else |
1793 |
|
raise Exception.CreateFmt(SNoReturnValue,[FName]); |
1794 |
|
|
1795 |
< |
Execute(FExternalContext,aProcMetadata,InputParams,OutputData[0]); |
1795 |
> |
Execute(FBContext,aProcMetadata,InputParams,OutputData[0]); |
1796 |
|
|
1797 |
|
if [loLogFunctions,loDetails] <= FBUDRControllerOptions.LogOptions then |
1798 |
< |
FController.WriteToLog(SOutputParams,OutputData); |
1798 |
> |
FController.WriteToLog(SOutputData,OutputData); |
1799 |
|
|
1800 |
|
OutParamsSQLDA.Finalise; {copy result to OutMsg buffer} |
1801 |
|
finally |
1840 |
|
begin |
1841 |
|
if FController = AValue then Exit; |
1842 |
|
FController := AValue; |
1847 |
– |
FFBContext := TFBUDRExternalContext.Create(Controller); |
1843 |
|
end; |
1844 |
|
|
1845 |
|
constructor TFBUDRFunctionFactory.Create(aName: AnsiString; |
1869 |
|
var FBRoutineMetadata: IFBUDRRoutineMetadata; |
1870 |
|
FBInBuilder: IFBUDRMetadataBuilder; |
1871 |
|
FBOutBuilder: IFBUDRMetadataBuilder; |
1872 |
+ |
FBContext: IFBUDRExternalContext; |
1873 |
|
begin |
1874 |
|
FBInBuilder := nil; |
1875 |
|
FBOutBuilder := nil; |
1877 |
|
if loLogFunctions in FBUDRControllerOptions.LogOptions then |
1878 |
|
FController.WriteToLog(SFuncSetup + FName); |
1879 |
|
|
1880 |
< |
(FFBContext as TFBUDRExternalContext).Assign(context); |
1880 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1881 |
|
|
1882 |
< |
FController.StartJournaling(FFBContext); |
1882 |
> |
FController.StartJournaling(FBContext); |
1883 |
|
|
1884 |
< |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FFBContext,metadata); |
1884 |
> |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1885 |
|
|
1886 |
|
if inBuilder <> nil then |
1887 |
< |
FBInBuilder := TFBUDRMetadataBuilder.Create(FFBContext,inBuilder); |
1887 |
> |
FBInBuilder := TFBUDRMetadataBuilder.Create(FBContext,inBuilder); |
1888 |
|
if outBuilder <> nil then |
1889 |
< |
FBOutBuilder := TFBUDRMetadataBuilder.Create(FFBContext,outBuilder); |
1889 |
> |
FBOutBuilder := TFBUDRMetadataBuilder.Create(FBContext,outBuilder); |
1890 |
|
if [loLogFunctions, loDetails] <= FBUDRControllerOptions.LogOptions then |
1891 |
|
FController.WriteToLog(SRoutineMetadata + LineEnding + (FBRoutineMetadata as TFBUDRRoutineMetadata).AsText); |
1892 |
|
|
1893 |
< |
TFBUDRFunction.setup(FFBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder) |
1893 |
> |
TFBUDRFunction.setup(FBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder) |
1894 |
|
except on E: Exception do |
1895 |
|
FController.FBSetStatusFromException(E,status); |
1896 |
|
end; |
1900 |
|
context: Firebird.IExternalContext; metadata: Firebird.IRoutineMetadata |
1901 |
|
): Firebird.IExternalFunction; |
1902 |
|
var FBRoutineMetadata: IFBUDRRoutineMetadata; |
1903 |
+ |
FBContext: IFBUDRExternalContext; |
1904 |
|
begin |
1905 |
|
try |
1906 |
< |
(FFBContext as TFBUDRExternalContext).Assign(context); |
1907 |
< |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FFBContext,metadata); |
1906 |
> |
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1907 |
> |
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1908 |
|
{Now get the argument Names} |
1909 |
< |
UpdateFieldNames(FFBContext.GetAttachment,FBRoutineMetadata.getName); |
1910 |
< |
Result := FFunction.Create(FController,FName,FFBContext,FBRoutineMetadata,FFieldNames); |
1909 |
> |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1910 |
> |
Result := FFunction.Create(FController,FName,FBRoutineMetadata,FFieldNames); |
1911 |
|
except on E: Exception do |
1912 |
|
FController.FBSetStatusFromException(E,status); |
1913 |
|
end; |
2199 |
|
FilePathName := ProcessTemplateMacros(FBUDRControllerOptions.LogFileNameTemplate); |
2200 |
|
if FJnlOpenAppend then |
2201 |
|
begin |
2202 |
< |
FLogStream := TFileStream.Create(FilePathName,fmOpenWrite); |
2202 |
> |
FLogStream := TFileStream.Create(FilePathName,fmOpenWrite or fmShareDenyNone); |
2203 |
|
FLogStream.Seek(0, soFromEnd); |
2204 |
|
end |
2205 |
|
else |
2206 |
< |
FLogStream := TFileStream.Create(FilePathName,fmCreate); |
2206 |
> |
FLogStream := TFileStream.Create(FilePathName,fmCreate or fmShareDenyNone); |
2207 |
|
end; |
2208 |
|
Result := FLogStream; |
2209 |
|
FJnlOpenAppend := true; |