182 |
|
procedure FreeMessageBuffer; override; |
183 |
|
function GetAttachment: IAttachment; override; |
184 |
|
function GetTransaction: ITransaction; override; |
185 |
+ |
function IsInputDataArea: boolean; override; |
186 |
|
public |
187 |
|
{created with the UDR output metadata and a pointer to the outMsg buffer.} |
188 |
|
constructor Create(context: IFBUDRExternalContext; aMetadata: Firebird.IMessageMetaData; aBuffer: PByte); |
225 |
|
procedure FreeMessageBuffer; override; |
226 |
|
function GetAttachment: IAttachment; override; |
227 |
|
function GetTransaction: ITransaction; override; |
228 |
+ |
function IsInputDataArea: boolean; override; |
229 |
|
public |
230 |
|
{created with the input messge metadata and a pointer to the inMsg buffer} |
231 |
|
constructor Create(context: IFBUDRExternalContext; |
247 |
|
FController: TFBUDRController; |
248 |
|
FName: AnsiString; |
249 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
248 |
– |
FFieldNames: TStrings; |
250 |
|
FFirebirdAPI: IFirebirdAPI; |
250 |
– |
procedure SetFieldNames(SQLDA: TFBUDRInParamsSQLDA); |
251 |
|
public |
252 |
|
constructor Create(aController: TFBUDRController; |
253 |
|
aName: AnsiString; |
254 |
< |
routineMetadata: IFBUDRRoutineMetadata; |
255 |
< |
aFieldNames: TStrings); |
254 |
> |
routineMetadata: IFBUDRRoutineMetadata); |
255 |
|
public |
256 |
|
{External Function Implementation} |
257 |
|
|
314 |
|
private |
315 |
|
FController: TFBUDRController; |
316 |
|
FName: AnsiString; |
318 |
– |
FFieldNames: TStringList; |
317 |
|
FFunction: TFBUDRFunctionClass; |
318 |
|
procedure SetController(AValue: TFBUDRController); |
321 |
– |
procedure UpdateFieldNames(att: IAttachment; aFunctionName: AnsiString); |
319 |
|
public |
320 |
|
constructor Create(aName: AnsiString; aFunction: TFBUDRFunctionClass); |
324 |
– |
destructor Destroy; override; |
321 |
|
property Controller: TFBUDRController read FController write SetController; |
322 |
|
public |
323 |
|
{IUdrFunctionFactory} |
344 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
345 |
|
FRefCount: integer; |
346 |
|
FFirebirdAPI: IFirebirdAPI; |
351 |
– |
protected |
352 |
– |
FInArgNames: TStrings; |
353 |
– |
FOutArgNames: TStrings; |
354 |
– |
procedure SetFieldNames(SQLDA: TSQLDataArea); |
347 |
|
public |
348 |
|
constructor Create(aController: TFBUDRController; |
349 |
|
aName: AnsiString; |
350 |
< |
routineMetadata: IFBUDRRoutineMetadata; |
359 |
< |
aInArgNames, aOutArgNames: TStrings); |
350 |
> |
routineMetadata: IFBUDRRoutineMetadata); |
351 |
|
property FirebirdAPI: IFirebirdAPI read FFirebirdAPI; |
352 |
|
public |
353 |
|
{External Procedure Implementation} |
389 |
|
FUDRProcedure: TFBUDRProcedure; |
390 |
|
FOutputDataSQLDA: TFBUDROutParamsSQLDA; |
391 |
|
FOutputData: IFBUDROutputData; |
401 |
– |
FOutArgNames: TStrings; |
402 |
– |
procedure SetFieldNames(SQLDA: TSQLDataArea); |
392 |
|
protected |
393 |
|
procedure Close; virtual; |
394 |
|
public |
395 |
|
constructor Create(UDRProcedure: TFBUDRProcedure; context: IFBUDRExternalContext; |
407 |
– |
aOutArgNames: TStrings; |
396 |
|
metadata: Firebird.IMessageMetadata; |
397 |
|
outMsg: pointer); |
398 |
|
destructor Destroy; override; |
510 |
|
FController: TFBUDRController; |
511 |
|
FName: AnsiString; |
512 |
|
FProcedure: TFBUDRProcedureClass; |
525 |
– |
FInArgNames: TStringList; |
526 |
– |
FOutArgNames: TStringList; |
513 |
|
procedure SetController(AValue: TFBUDRController); |
528 |
– |
procedure UpdateArgNames(att: IAttachment; aProcName: AnsiString); |
514 |
|
public |
515 |
|
constructor Create(aName: AnsiString; aProcedure: TFBUDRProcedureClass); |
531 |
– |
destructor Destroy; override; |
516 |
|
property Controller: TFBUDRController read FController write SetController; |
517 |
|
public |
518 |
|
{IUdrProcedureFactory} |
540 |
|
FController: TFBUDRController; |
541 |
|
FName: AnsiString; |
542 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
559 |
– |
FFieldNames: TStrings; |
543 |
|
FFirebirdAPI: IFirebirdAPI; |
561 |
– |
procedure SetFieldNames(SQLDA: TSQLDataArea); |
544 |
|
public |
545 |
|
constructor Create(aController: TFBUDRController; |
546 |
|
aName: AnsiString; |
547 |
< |
routineMetadata: IFBUDRRoutineMetadata; |
566 |
< |
aFieldNames: TStrings); |
547 |
> |
routineMetadata: IFBUDRRoutineMetadata); |
548 |
|
public |
549 |
|
{External Trigger Implementation} |
550 |
|
|
619 |
|
FController: TFBUDRController; |
620 |
|
FName: AnsiString; |
621 |
|
FTrigger: TFBUDRTriggerClass; |
641 |
– |
FFieldNames: TStringList; |
622 |
|
procedure SetController(AValue: TFBUDRController); |
643 |
– |
procedure UpdateFieldNames(att: IAttachment; aTableName: AnsiString); |
623 |
|
public |
624 |
|
constructor Create(aName: AnsiString; aTrigger: TFBUDRTriggerClass); |
646 |
– |
destructor Destroy; override; |
625 |
|
property Controller: TFBUDRController read FController write SetController; |
626 |
|
public |
627 |
|
procedure dispose(); override; |
880 |
|
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
881 |
|
metadata, |
882 |
|
inMsg); |
905 |
– |
SetFieldNames(InputParamsSQLDA); |
883 |
|
finally |
884 |
|
metadata.release; |
885 |
|
end; |
898 |
|
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
899 |
|
|
900 |
|
try |
901 |
< |
Result := TFBUDRSingletonRow.Create(self, FBContext, FOutArgNames, |
901 |
> |
Result := TFBUDRSingletonRow.Create(self, FBContext, |
902 |
|
metadata, |
903 |
|
outMsg); |
904 |
|
|
975 |
|
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
976 |
|
metadata, |
977 |
|
inMsg); |
1001 |
– |
SetFieldNames(InputParamsSQLDA); |
978 |
|
finally |
979 |
|
metadata.release; |
980 |
|
end; |
995 |
|
try |
996 |
|
open(FBContext,aProcMetadata,InputParams); |
997 |
|
Result := TFBUDRResultsCursor.Create(self, FBContext, |
1022 |
– |
FOutArgNames, |
998 |
|
metadata, |
999 |
|
outMsg); |
1000 |
|
finally |
1021 |
|
end; |
1022 |
|
end; |
1023 |
|
|
1049 |
– |
const |
1050 |
– |
sGetFieldNamesSQL = 'Select Trim(RF.RDB$FIELD_NAME) as ColumnName '+ |
1051 |
– |
'FROM RDB$RELATION_FIELDS RF '+ |
1052 |
– |
'JOIN RDB$FIELDS B On B.RDB$FIELD_NAME = RF.RDB$FIELD_SOURCE '+ |
1053 |
– |
'Where RF.RDB$RELATION_NAME = ? ' + |
1054 |
– |
'order by RF.RDB$FIELD_POSITION asc'; |
1055 |
– |
|
1024 |
|
{ TFBUDRTriggerFactory } |
1025 |
|
|
1058 |
– |
procedure TFBUDRTriggerFactory.UpdateFieldNames(att: IAttachment; |
1059 |
– |
aTableName: AnsiString); |
1060 |
– |
var FieldNames: IResultSet; |
1061 |
– |
begin |
1062 |
– |
FFieldNames.Clear; |
1063 |
– |
if aTableName = '' then |
1064 |
– |
Exit; |
1065 |
– |
FieldNames := att.OpenCursorAtStart(sGetFieldNamesSQL,[aTableName]); |
1066 |
– |
while not FieldNames.IsEOF do |
1067 |
– |
begin |
1068 |
– |
FFieldNames.Add(FieldNames[0].AsString); |
1069 |
– |
FieldNames.FetchNext; |
1070 |
– |
end; |
1071 |
– |
end; |
1072 |
– |
|
1026 |
|
procedure TFBUDRTriggerFactory.SetController(AValue: TFBUDRController); |
1027 |
|
begin |
1028 |
|
if FController = AValue then Exit; |
1035 |
|
inherited Create; |
1036 |
|
FName := aName; |
1037 |
|
FTrigger := aTrigger; |
1085 |
– |
FFieldNames := TStringList.Create; |
1086 |
– |
end; |
1087 |
– |
|
1088 |
– |
destructor TFBUDRTriggerFactory.Destroy; |
1089 |
– |
begin |
1090 |
– |
if FFieldNames <> nil then |
1091 |
– |
FFieldNames.Free; |
1092 |
– |
inherited Destroy; |
1038 |
|
end; |
1039 |
|
|
1040 |
|
procedure TFBUDRTriggerFactory.dispose(); |
1057 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1058 |
|
|
1059 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1115 |
– |
{Now get the Field Names} |
1116 |
– |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getTriggerTable); |
1117 |
– |
|
1060 |
|
if fieldsBuilder <> nil then |
1061 |
|
FBFieldsBuilder := TFBUDRMetadataBuilder.Create(FBContext,fieldsBuilder); |
1062 |
|
if [loLogTriggers, loDetails] <= FBUDRControllerOptions.LogOptions then |
1063 |
|
FController.WriteToLog(SRoutineMetadata + LineEnding + (FBRoutineMetadata as TFBUDRRoutineMetadata).AsText); |
1064 |
< |
TFBUDRTrigger.setup(FBContext,FBRoutineMetadata,FBFieldsBuilder) |
1064 |
> |
TFBUDRTrigger.setup(FBContext,FBRoutineMetadata,FBFieldsBuilder); |
1065 |
|
except on E: Exception do |
1066 |
|
FController.FBSetStatusFromException(E,status); |
1067 |
|
end; |
1076 |
|
try |
1077 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1078 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1079 |
< |
Result := FTrigger.Create(FController,FName,FBRoutineMetadata,FFieldNames); |
1079 |
> |
Result := FTrigger.Create(FController,FName,FBRoutineMetadata); |
1080 |
|
except on E: Exception do |
1081 |
|
FController.FBSetStatusFromException(E,status); |
1082 |
|
end; |
1084 |
|
|
1085 |
|
{ TFBUDRTrigger } |
1086 |
|
|
1145 |
– |
procedure TFBUDRTrigger.SetFieldNames(SQLDA: TSQLDataArea); |
1146 |
– |
var i: integer; |
1147 |
– |
begin |
1148 |
– |
for i := 0 to FFieldNames.Count - 1 do |
1149 |
– |
if i < SQLDA.Count then |
1150 |
– |
SQLDA[i].Name := FFieldNames[i]; |
1151 |
– |
end; |
1152 |
– |
|
1087 |
|
constructor TFBUDRTrigger.Create(aController: TFBUDRController; |
1088 |
< |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata; |
1155 |
< |
aFieldNames: TStrings); |
1088 |
> |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata); |
1089 |
|
begin |
1090 |
|
inherited Create; |
1091 |
|
FName := aName; |
1092 |
|
FController := aController; |
1093 |
|
FRoutineMetaData := routineMetadata; |
1161 |
– |
FFieldNames := aFieldNames; |
1094 |
|
end; |
1095 |
|
|
1096 |
|
function TFBUDRTrigger.getCharSet(context: IFBUDRExternalContext): AnsiString; |
1177 |
|
OldParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
1178 |
|
metadata, |
1179 |
|
oldMsg); |
1248 |
– |
SetFieldNames(OldParamsSQLDA); |
1180 |
|
OldParams := TFBUDRInputParams.Create(OldParamsSQLDA); |
1181 |
|
if [loLogTriggers,loDetails] <= FBUDRControllerOptions.LogOptions then |
1182 |
|
begin |
1195 |
|
NewParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
1196 |
|
metadata, |
1197 |
|
newMsg); |
1267 |
– |
SetFieldNames(NewParamsSQLDA); |
1198 |
|
NewParams := TFBUDRInputParams.Create(NewParamsSQLDA); |
1199 |
|
if [loLogTriggers,loDetails] <= FBUDRControllerOptions.LogOptions then |
1200 |
|
begin |
1213 |
|
WritableParamsSQLDA := TFBUDRTriggerNewValuesSQLDA.Create(FBContext, |
1214 |
|
metadata, |
1215 |
|
newMsg); |
1286 |
– |
SetFieldNames(WritableParamsSQLDA); |
1216 |
|
NewWritableParams := TFBUDROutputParams.Create(WritableParamsSQLDA); |
1217 |
|
if [loLogTriggers,loDetails] <= FBUDRControllerOptions.LogOptions then |
1218 |
|
begin |
1273 |
|
if TriggerAction in [taUpdate, taDelete] then |
1274 |
|
SetUpOldParams; |
1275 |
|
if TriggerAction in [taInsert,taUpdate] then |
1276 |
< |
SetupWritableNewParams; |
1276 |
> |
SetupWritableNewParams; |
1277 |
|
end; |
1278 |
|
BeforeTrigger(FBContext,aTriggerMetadata,TriggerAction,OldParams,NewWritableParams); |
1279 |
|
WritableParamsSQLDA.Finalise; |
1280 |
|
if [loLogTriggers,loDetails] <= FBUDRControllerOptions.LogOptions then |
1281 |
|
FController.WriteToLog(STriggerNewAfter,NewWritableParams); |
1282 |
< |
end; |
1282 |
> |
end; |
1283 |
|
ttAfter: |
1284 |
|
begin |
1285 |
|
if FRoutineMetadata.HasTriggerMetadata then |
1314 |
|
end; |
1315 |
|
end; |
1316 |
|
|
1388 |
– |
const |
1389 |
– |
sGetProcArgsSQL = |
1390 |
– |
'SELECT Trim(RDB$PARAMETER_NAME) ' + |
1391 |
– |
' FROM RDB$PROCEDURE_PARAMETERS PRM JOIN RDB$FIELDS FLD ON ' + |
1392 |
– |
' PRM.RDB$FIELD_SOURCE = FLD.RDB$FIELD_NAME ' + |
1393 |
– |
'WHERE ' + |
1394 |
– |
' Trim(PRM.RDB$PROCEDURE_NAME) = ? AND ' + |
1395 |
– |
' PRM.RDB$PARAMETER_TYPE = ? ' + |
1396 |
– |
'ORDER BY PRM.RDB$PARAMETER_NUMBER'; |
1397 |
– |
|
1398 |
– |
|
1317 |
|
{ TFBUDRProcedureFactory } |
1318 |
|
|
1401 |
– |
procedure TFBUDRProcedureFactory.UpdateArgNames(att: IAttachment; |
1402 |
– |
aProcName: AnsiString); |
1403 |
– |
|
1404 |
– |
procedure UpdateFieldNames(paramType: integer; list: TStrings); |
1405 |
– |
var FieldNames: IResultSet; |
1406 |
– |
begin |
1407 |
– |
list.Clear; |
1408 |
– |
if aProcName = '' then |
1409 |
– |
Exit; |
1410 |
– |
FieldNames := att.OpenCursorAtStart(sGetProcArgsSQL,[aProcName,paramType]); |
1411 |
– |
while not FieldNames.IsEOF do |
1412 |
– |
begin |
1413 |
– |
list.Add(FieldNames[0].AsString); |
1414 |
– |
FieldNames.FetchNext; |
1415 |
– |
end; |
1416 |
– |
end; |
1417 |
– |
|
1418 |
– |
begin |
1419 |
– |
UpdateFieldNames(0,FInArgNames); |
1420 |
– |
UpdateFieldNames(1,FOutArgNames); |
1421 |
– |
end; |
1422 |
– |
|
1319 |
|
procedure TFBUDRProcedureFactory.SetController(AValue: TFBUDRController); |
1320 |
|
begin |
1321 |
|
if FController = AValue then Exit; |
1328 |
|
inherited Create; |
1329 |
|
FName := aName; |
1330 |
|
FProcedure := aProcedure; |
1435 |
– |
FInArgNames := TStringList.Create; |
1436 |
– |
FOutArgNames := TStringList.Create; |
1437 |
– |
end; |
1438 |
– |
|
1439 |
– |
destructor TFBUDRProcedureFactory.Destroy; |
1440 |
– |
begin |
1441 |
– |
if FInArgNames <> nil then |
1442 |
– |
FInArgNames.Free; |
1443 |
– |
if FOutArgNames <> nil then |
1444 |
– |
FOutArgNames.Free; |
1445 |
– |
inherited Destroy; |
1331 |
|
end; |
1332 |
|
|
1333 |
|
procedure TFBUDRProcedureFactory.dispose(); |
1352 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1353 |
|
|
1354 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1470 |
– |
{Now get the Field Names} |
1471 |
– |
UpdateArgNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1355 |
|
if inBuilder <> nil then |
1356 |
|
FBInBuilder := TFBUDRMetadataBuilder.Create(FBContext,inBuilder); |
1357 |
|
if outBuilder <> nil then |
1358 |
|
FBOutBuilder := TFBUDRMetadataBuilder.Create(FBContext,outBuilder); |
1359 |
|
if [loLogProcedures, loDetails] <= FBUDRControllerOptions.LogOptions then |
1360 |
|
FController.WriteToLog(SRoutineMetadata + LineEnding + (FBRoutineMetadata as TFBUDRRoutineMetadata).AsText); |
1361 |
< |
TFBUDRProcedure.setup(FBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder) |
1361 |
> |
TFBUDRProcedure.setup(FBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder); |
1362 |
|
except on E: Exception do |
1363 |
|
FController.FBSetStatusFromException(E,status); |
1364 |
|
end; |
1373 |
|
try |
1374 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1375 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1376 |
< |
Result := FProcedure.Create(FController,FName,FBRoutineMetadata, |
1494 |
< |
FInArgNames,FOutArgNames); |
1376 |
> |
Result := FProcedure.Create(FController,FName,FBRoutineMetadata); |
1377 |
|
except on E: Exception do |
1378 |
|
FController.FBSetStatusFromException(E,status); |
1379 |
|
end; |
1381 |
|
|
1382 |
|
{ TFBUDRExternalResultsSet } |
1383 |
|
|
1502 |
– |
procedure TFBUDRExternalResultsSet.SetFieldNames(SQLDA: TSQLDataArea); |
1503 |
– |
var i: integer; |
1504 |
– |
begin |
1505 |
– |
for i := 0 to FOutArgNames.Count - 1 do |
1506 |
– |
if i < SQLDA.Count then |
1507 |
– |
SQLDA[i].Name := FOutArgNames[i]; |
1508 |
– |
end; |
1509 |
– |
|
1384 |
|
procedure TFBUDRExternalResultsSet.Close; |
1385 |
|
begin |
1386 |
|
//do nothing by default |
1387 |
|
end; |
1388 |
|
|
1389 |
|
constructor TFBUDRExternalResultsSet.Create(UDRProcedure: TFBUDRProcedure; |
1390 |
< |
context: IFBUDRExternalContext; aOutArgNames: TStrings; |
1391 |
< |
metadata: Firebird.IMessageMetadata; outMsg: pointer); |
1390 |
> |
context: IFBUDRExternalContext; metadata: Firebird.IMessageMetadata; |
1391 |
> |
outMsg: pointer); |
1392 |
|
begin |
1393 |
|
inherited Create; |
1394 |
|
FUDRProcedure := UDRProcedure; |
1521 |
– |
FOutArgNames := aOutArgNames; |
1395 |
|
Inc(FUDRProcedure.FRefCount); |
1396 |
|
if metadata <> nil then |
1397 |
|
begin |
1398 |
|
FOutputDataSQLDA := TFBUDROutParamsSQLDA.Create(context,metadata,outMsg); |
1526 |
– |
SetFieldNames(FOutputDataSQLDA); |
1399 |
|
FOutputData := TFBUDROutputParams.Create(FOutputDataSQLDA); |
1400 |
|
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
1401 |
|
FUDRProcedure.FController.WriteToLog(SOutputParams,FOutputData); |
1419 |
|
|
1420 |
|
{ TFBUDRProcedure } |
1421 |
|
|
1550 |
– |
procedure TFBUDRProcedure.SetFieldNames(SQLDA: TSQLDataArea); |
1551 |
– |
var i: integer; |
1552 |
– |
begin |
1553 |
– |
for i := 0 to FInArgNames.Count - 1 do |
1554 |
– |
if i < SQLDA.Count then |
1555 |
– |
SQLDA[i].Name := FInArgNames[i]; |
1556 |
– |
end; |
1557 |
– |
|
1422 |
|
constructor TFBUDRProcedure.Create(aController: TFBUDRController; |
1423 |
< |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata; aInArgNames, |
1560 |
< |
aOutArgNames: TStrings); |
1423 |
> |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata); |
1424 |
|
begin |
1425 |
|
inherited Create; |
1426 |
|
FController := aController; |
1427 |
|
FName := aName; |
1428 |
|
FRefCount := 1; |
1429 |
|
FRoutineMetaData := routineMetadata; |
1567 |
– |
FInArgNames := aInArgNames; |
1568 |
– |
FOutArgNames := aOutArgNames; |
1430 |
|
end; |
1431 |
|
|
1432 |
|
function TFBUDRProcedure.getCharSet(context: IFBUDRExternalContext): AnsiString; |
1498 |
|
Result := FTransaction; |
1499 |
|
end; |
1500 |
|
|
1501 |
+ |
function TFBUDRInParamsSQLDA.IsInputDataArea: boolean; |
1502 |
+ |
begin |
1503 |
+ |
Result := true; |
1504 |
+ |
end; |
1505 |
+ |
|
1506 |
|
constructor TFBUDRInParamsSQLDA.Create(context: IFBUDRExternalContext; |
1507 |
|
aMetadata: Firebird.IMessageMetaData; aBuffer: PByte); |
1508 |
|
begin |
1538 |
|
Result := FTransaction; |
1539 |
|
end; |
1540 |
|
|
1541 |
+ |
function TFBUDROutParamsSQLDA.IsInputDataArea: boolean; |
1542 |
+ |
begin |
1543 |
+ |
Result := true; |
1544 |
+ |
end; |
1545 |
+ |
|
1546 |
|
constructor TFBUDROutParamsSQLDA.Create(context: IFBUDRExternalContext; |
1547 |
|
aMetadata: Firebird.IMessageMetaData; aBuffer: PByte); |
1548 |
|
begin |
1565 |
|
|
1566 |
|
{ TFBUDRFunction } |
1567 |
|
|
1697 |
– |
procedure TFBUDRFunction.SetFieldNames(SQLDA: TFBUDRInParamsSQLDA); |
1698 |
– |
var i: integer; |
1699 |
– |
begin |
1700 |
– |
for i := 0 to FFieldNames.Count - 1 do |
1701 |
– |
if i < SQLDA.Count then |
1702 |
– |
SQLDA[i].Name := FFieldNames[i]; |
1703 |
– |
end; |
1704 |
– |
|
1568 |
|
constructor TFBUDRFunction.Create(aController: TFBUDRController; |
1569 |
< |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata; |
1707 |
< |
aFieldNames: TStrings); |
1569 |
> |
aName: AnsiString; routineMetadata: IFBUDRRoutineMetadata); |
1570 |
|
begin |
1571 |
|
inherited Create; |
1572 |
|
FController := aController; |
1573 |
|
FName := aName; |
1712 |
– |
FFieldNames := aFieldNames; |
1574 |
|
FRoutineMetaData := routineMetadata; |
1575 |
|
if loLogFunctions in FBUDRControllerOptions.LogOptions then |
1576 |
|
begin |
1673 |
|
InParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
1674 |
|
metadata, |
1675 |
|
inMsg); |
1815 |
– |
SetFieldNames(InParamsSQLDA); |
1676 |
|
finally |
1677 |
|
metadata.release; |
1678 |
|
end; |
1720 |
|
|
1721 |
|
{ TFBUDRFunctionFactory } |
1722 |
|
|
1863 |
– |
const |
1864 |
– |
FunctionArgsSQL = |
1865 |
– |
'SELECT Trim(RDB$ARGUMENT_NAME) FROM RDB$FUNCTION_ARGUMENTS RFA JOIN RDB$FIELDS FLD ' + |
1866 |
– |
'ON RFA.RDB$FIELD_SOURCE = FLD.RDB$FIELD_NAME '+ |
1867 |
– |
'WHERE RDB$FUNCTION_NAME = ? AND RDB$ARGUMENT_POSITION > 0' + |
1868 |
– |
'ORDER BY RDB$ARGUMENT_POSITION'; |
1869 |
– |
|
1870 |
– |
procedure TFBUDRFunctionFactory.UpdateFieldNames(att: IAttachment; |
1871 |
– |
aFunctionName: AnsiString); |
1872 |
– |
var FieldNames: IResultSet; |
1873 |
– |
begin |
1874 |
– |
FFieldNames.Clear; |
1875 |
– |
if aFunctionName = '' then |
1876 |
– |
Exit; |
1877 |
– |
FieldNames := att.OpenCursorAtStart(FunctionArgsSQL,[aFunctionName]); |
1878 |
– |
while not FieldNames.IsEOF do |
1879 |
– |
begin |
1880 |
– |
FFieldNames.Add(FieldNames[0].AsString); |
1881 |
– |
FieldNames.FetchNext; |
1882 |
– |
end; |
1883 |
– |
end; |
1884 |
– |
|
1723 |
|
procedure TFBUDRFunctionFactory.SetController(AValue: TFBUDRController); |
1724 |
|
begin |
1725 |
|
if FController = AValue then Exit; |
1732 |
|
inherited Create; |
1733 |
|
FName := aName; |
1734 |
|
FFunction := aFunction; |
1897 |
– |
FFieldNames := TStringList.Create; |
1898 |
– |
end; |
1899 |
– |
|
1900 |
– |
destructor TFBUDRFunctionFactory.Destroy; |
1901 |
– |
begin |
1902 |
– |
if FFieldNames <> nil then |
1903 |
– |
FFieldNames.Free; |
1904 |
– |
inherited Destroy; |
1735 |
|
end; |
1736 |
|
|
1737 |
|
procedure TFBUDRFunctionFactory.dispose(); |
1756 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1757 |
|
|
1758 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1929 |
– |
{Now get the argument Names} |
1930 |
– |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1759 |
|
|
1760 |
|
if inBuilder <> nil then |
1761 |
|
FBInBuilder := TFBUDRMetadataBuilder.Create(FBContext,inBuilder); |
1764 |
|
if [loLogFunctions, loDetails] <= FBUDRControllerOptions.LogOptions then |
1765 |
|
FController.WriteToLog(SRoutineMetadata + LineEnding + (FBRoutineMetadata as TFBUDRRoutineMetadata).AsText); |
1766 |
|
|
1767 |
< |
TFBUDRFunction.setup(FBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder) |
1767 |
> |
TFBUDRFunction.setup(FBContext,FBRoutineMetadata,FBInBuilder,FBOutBuilder); |
1768 |
|
except on E: Exception do |
1769 |
|
FController.FBSetStatusFromException(E,status); |
1770 |
|
end; |
1779 |
|
try |
1780 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1781 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1782 |
< |
Result := FFunction.Create(FController,FName,FBRoutineMetadata,FFieldNames); |
1782 |
> |
Result := FFunction.Create(FController,FName,FBRoutineMetadata); |
1783 |
|
except on E: Exception do |
1784 |
|
FController.FBSetStatusFromException(E,status); |
1785 |
|
end; |