246 |
|
FName: AnsiString; |
247 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
248 |
|
FFieldNames: TStrings; |
249 |
+ |
FFirebirdAPI: IFirebirdAPI; |
250 |
|
procedure SetFieldNames(SQLDA: TFBUDRInParamsSQLDA); |
251 |
|
public |
252 |
|
constructor Create(aController: TFBUDRController; |
288 |
|
outBuilder: IFBUDRMetadataBuilder); virtual; |
289 |
|
property Name: AnsiString read FName; |
290 |
|
property Controller: TFBUDRController read FController; |
291 |
+ |
property FirebirdAPI: IFirebirdAPI read FFirebirdAPI; |
292 |
|
public |
293 |
|
{IExternalFunction} |
294 |
|
procedure dispose(); override; |
347 |
|
FName: AnsiString; |
348 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
349 |
|
FRefCount: integer; |
350 |
+ |
FFirebirdAPI: IFirebirdAPI; |
351 |
|
protected |
352 |
|
FInArgNames: TStrings; |
353 |
|
FOutArgNames: TStrings; |
357 |
|
aName: AnsiString; |
358 |
|
routineMetadata: IFBUDRRoutineMetadata; |
359 |
|
aInArgNames, aOutArgNames: TStrings); |
360 |
+ |
property FirebirdAPI: IFirebirdAPI read FFirebirdAPI; |
361 |
|
public |
362 |
|
{External Procedure Implementation} |
363 |
|
|
557 |
|
FName: AnsiString; |
558 |
|
FRoutineMetadata: IFBUDRRoutineMetadata; |
559 |
|
FFieldNames: TStrings; |
560 |
+ |
FFirebirdAPI: IFirebirdAPI; |
561 |
|
procedure SetFieldNames(SQLDA: TSQLDataArea); |
562 |
|
public |
563 |
|
constructor Create(aController: TFBUDRController; |
613 |
|
|
614 |
|
property Name: AnsiString read FName; |
615 |
|
property Controller: TFBUDRController read FController; |
616 |
+ |
property FirebirdAPI: IFirebirdAPI read FFirebirdAPI; |
617 |
|
public |
618 |
|
{IExternalTrigger} |
619 |
|
procedure dispose(); override; |
819 |
|
|
820 |
|
function TFBUDRResultsCursor.fetch(status: Firebird.IStatus): Boolean; |
821 |
|
begin |
822 |
+ |
Result := false; |
823 |
|
try |
824 |
|
if loLogFetches in FBUDRControllerOptions.LogOptions then |
825 |
|
FUDRProcedure.FController.WriteToLog(SFetchCalled + FUDRProcedure.FName); |
890 |
|
else |
891 |
|
begin |
892 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
893 |
< |
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(FBContext, |
894 |
< |
metadata, |
895 |
< |
inMsg); |
896 |
< |
SetFieldNames(InputParamsSQLDA); |
897 |
< |
finally |
898 |
< |
metadata.release; |
899 |
< |
end; |
900 |
< |
end; |
901 |
< |
|
893 |
> |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
894 |
|
try |
895 |
< |
if InputParamsSQLDA <> nil then |
895 |
> |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
896 |
> |
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
897 |
> |
|
898 |
> |
if FRoutineMetadata.HasInputMetadata then |
899 |
|
begin |
900 |
< |
InputParams := TFBUDRInputParams.Create(InputParamsSQLDA); |
901 |
< |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
902 |
< |
FController.WriteToLog(SInputParams,InputParams); |
900 |
> |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getInputMetadata; |
901 |
> |
try |
902 |
> |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
903 |
> |
metadata, |
904 |
> |
inMsg); |
905 |
> |
SetFieldNames(InputParamsSQLDA); |
906 |
> |
finally |
907 |
> |
metadata.release; |
908 |
> |
end; |
909 |
|
end; |
910 |
|
|
910 |
– |
metadata := nil; |
911 |
– |
if FRoutineMetadata.HasOutputMetadata then |
912 |
– |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
913 |
– |
|
911 |
|
try |
912 |
< |
Result := TFBUDRSingletonRow.Create(self, FBContext, FOutArgNames, |
913 |
< |
metadata, |
914 |
< |
outMsg); |
912 |
> |
if InputParamsSQLDA <> nil then |
913 |
> |
begin |
914 |
> |
InputParams := TFBUDRInputParams.Create(InputParamsSQLDA); |
915 |
> |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
916 |
> |
FController.WriteToLog(SInputParams,InputParams); |
917 |
> |
end; |
918 |
> |
|
919 |
> |
metadata := nil; |
920 |
> |
if FRoutineMetadata.HasOutputMetadata then |
921 |
> |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
922 |
|
|
923 |
+ |
try |
924 |
+ |
Result := TFBUDRSingletonRow.Create(self, FBContext, FOutArgNames, |
925 |
+ |
metadata, |
926 |
+ |
outMsg); |
927 |
+ |
|
928 |
+ |
finally |
929 |
+ |
if metadata <> nil then |
930 |
+ |
metadata.release; |
931 |
+ |
end; |
932 |
+ |
|
933 |
+ |
Execute(FBContext,aProcMetadata,InputParams, |
934 |
+ |
(Result as TFBUDRSingletonRow).OutputData); |
935 |
|
finally |
936 |
< |
if metadata <> nil then |
937 |
< |
metadata.release; |
936 |
> |
InputParams := nil; |
937 |
> |
if InputParamsSQLDA <> nil then |
938 |
> |
InputParamsSQLDA.Free; |
939 |
|
end; |
940 |
|
|
924 |
– |
Execute(FBContext,aProcMetadata,InputParams, |
925 |
– |
(Result as TFBUDRSingletonRow).OutputData); |
941 |
|
finally |
942 |
< |
InputParams := nil; |
928 |
< |
if InputParamsSQLDA <> nil then |
929 |
< |
InputParamsSQLDA.Free; |
942 |
> |
FFirebirdAPI := nil; |
943 |
|
end; |
944 |
|
|
945 |
|
end; |
986 |
|
else |
987 |
|
begin |
988 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
989 |
< |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
977 |
< |
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
978 |
< |
|
979 |
< |
if FRoutineMetadata.HasInputMetadata then |
980 |
< |
begin |
981 |
< |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getInputMetadata; |
982 |
< |
try |
983 |
< |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
984 |
< |
metadata, |
985 |
< |
inMsg); |
986 |
< |
SetFieldNames(InputParamsSQLDA); |
987 |
< |
finally |
988 |
< |
metadata.release; |
989 |
< |
end; |
990 |
< |
end; |
991 |
< |
|
989 |
> |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
990 |
|
try |
991 |
< |
if InputParamsSQLDA <> nil then |
991 |
> |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
992 |
> |
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
993 |
> |
|
994 |
> |
if FRoutineMetadata.HasInputMetadata then |
995 |
|
begin |
996 |
< |
InputParams := TFBUDRInputParams.Create(InputParamsSQLDA); |
997 |
< |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
998 |
< |
FController.WriteToLog(SInputParams,InputParams); |
996 |
> |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getInputMetadata; |
997 |
> |
try |
998 |
> |
InputParamsSQLDA := TFBUDRInParamsSQLDA.Create(FBContext, |
999 |
> |
metadata, |
1000 |
> |
inMsg); |
1001 |
> |
SetFieldNames(InputParamsSQLDA); |
1002 |
> |
finally |
1003 |
> |
metadata.release; |
1004 |
> |
end; |
1005 |
|
end; |
1006 |
|
|
1000 |
– |
metadata := nil; |
1001 |
– |
if FRoutineMetadata.HasOutputMetadata then |
1002 |
– |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
1003 |
– |
|
1007 |
|
try |
1008 |
< |
open(FBContext,aProcMetadata,InputParams); |
1009 |
< |
Result := TFBUDRResultsCursor.Create(self, FBContext, |
1010 |
< |
FOutArgNames, |
1011 |
< |
metadata, |
1012 |
< |
outMsg); |
1008 |
> |
if InputParamsSQLDA <> nil then |
1009 |
> |
begin |
1010 |
> |
InputParams := TFBUDRInputParams.Create(InputParamsSQLDA); |
1011 |
> |
if [loLogProcedures,loDetails] <= FBUDRControllerOptions.LogOptions then |
1012 |
> |
FController.WriteToLog(SInputParams,InputParams); |
1013 |
> |
end; |
1014 |
> |
|
1015 |
> |
metadata := nil; |
1016 |
> |
if FRoutineMetadata.HasOutputMetadata then |
1017 |
> |
metadata := (FRoutineMetadata as TFBUDRRoutineMetadata).getOutputMetadata; |
1018 |
> |
|
1019 |
> |
try |
1020 |
> |
open(FBContext,aProcMetadata,InputParams); |
1021 |
> |
Result := TFBUDRResultsCursor.Create(self, FBContext, |
1022 |
> |
FOutArgNames, |
1023 |
> |
metadata, |
1024 |
> |
outMsg); |
1025 |
> |
finally |
1026 |
> |
if metadata <> nil then |
1027 |
> |
metadata.release; |
1028 |
> |
end; |
1029 |
|
finally |
1030 |
< |
if metadata <> nil then |
1031 |
< |
metadata.release; |
1030 |
> |
InputParams := nil; |
1031 |
> |
if InputParamsSQLDA <> nil then |
1032 |
> |
InputParamsSQLDA.Free; |
1033 |
|
end; |
1034 |
|
finally |
1035 |
< |
InputParams := nil; |
1016 |
< |
if InputParamsSQLDA <> nil then |
1017 |
< |
InputParamsSQLDA.Free; |
1035 |
> |
FFirebirdAPI := nil; |
1036 |
|
end; |
1037 |
|
end; |
1038 |
+ |
|
1039 |
|
except on E: Exception do |
1040 |
|
begin |
1041 |
|
if Result <> nil then |
1112 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1113 |
|
|
1114 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1115 |
+ |
{Now get the Field Names} |
1116 |
+ |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getTriggerTable); |
1117 |
|
|
1118 |
|
if fieldsBuilder <> nil then |
1119 |
|
FBFieldsBuilder := TFBUDRMetadataBuilder.Create(FBContext,fieldsBuilder); |
1134 |
|
try |
1135 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1136 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1116 |
– |
{Now get the Field Names} |
1117 |
– |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getTriggerTable); |
1137 |
|
Result := FTrigger.Create(FController,FName,FBRoutineMetadata,FFieldNames); |
1138 |
|
except on E: Exception do |
1139 |
|
FController.FBSetStatusFromException(E,status); |
1207 |
|
begin |
1208 |
|
try |
1209 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1210 |
< |
charset := getCharSet(FBContext); |
1211 |
< |
if charset <> '' then |
1212 |
< |
begin |
1213 |
< |
StrPLCopy(name,charset,nameSize); |
1214 |
< |
if loLogTriggers in FBUDRControllerOptions.LogOptions then |
1215 |
< |
FController.WriteToLog(Format(STriggerCharset,[FName,charset])); |
1210 |
> |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
1211 |
> |
try |
1212 |
> |
charset := getCharSet(FBContext); |
1213 |
> |
if charset <> '' then |
1214 |
> |
begin |
1215 |
> |
StrPLCopy(name,charset,nameSize); |
1216 |
> |
if loLogTriggers in FBUDRControllerOptions.LogOptions then |
1217 |
> |
FController.WriteToLog(Format(STriggerCharset,[FName,charset])); |
1218 |
> |
end; |
1219 |
> |
finally |
1220 |
> |
FFirebirdAPI := nil; |
1221 |
|
end; |
1222 |
|
except on E: Exception do |
1223 |
|
FController.FBSetStatusFromException(E,status); |
1310 |
|
else |
1311 |
|
begin |
1312 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1313 |
< |
|
1290 |
< |
with Firebird.IExternalTrigger do |
1291 |
< |
case action of |
1292 |
< |
ACTION_INSERT: |
1293 |
< |
TriggerAction := taInsert; |
1294 |
< |
ACTION_UPDATE: |
1295 |
< |
TriggerAction := taUpdate; |
1296 |
< |
ACTION_DELETE: |
1297 |
< |
TriggerAction := taDelete; |
1298 |
< |
ACTION_CONNECT: |
1299 |
< |
TriggerAction := taConnect; |
1300 |
< |
ACTION_DISCONNECT: |
1301 |
< |
TriggerAction := taDisconnect; |
1302 |
< |
ACTION_TRANS_START: |
1303 |
< |
TriggerAction := taTransactionStart; |
1304 |
< |
ACTION_TRANS_COMMIT: |
1305 |
< |
TriggerAction := taTransactionCommit; |
1306 |
< |
ACTION_TRANS_ROLLBACK: |
1307 |
< |
TriggerAction := taTransactionRollback; |
1308 |
< |
ACTION_DDL: |
1309 |
< |
TriggerAction := taDDL; |
1310 |
< |
else |
1311 |
< |
FBUDRError(ibxeUnknownTransactionAction,[action]); |
1312 |
< |
end; |
1313 |
< |
|
1313 |
> |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
1314 |
|
try |
1315 |
+ |
with Firebird.IExternalTrigger do |
1316 |
+ |
case action of |
1317 |
+ |
ACTION_INSERT: |
1318 |
+ |
TriggerAction := taInsert; |
1319 |
+ |
ACTION_UPDATE: |
1320 |
+ |
TriggerAction := taUpdate; |
1321 |
+ |
ACTION_DELETE: |
1322 |
+ |
TriggerAction := taDelete; |
1323 |
+ |
ACTION_CONNECT: |
1324 |
+ |
TriggerAction := taConnect; |
1325 |
+ |
ACTION_DISCONNECT: |
1326 |
+ |
TriggerAction := taDisconnect; |
1327 |
+ |
ACTION_TRANS_START: |
1328 |
+ |
TriggerAction := taTransactionStart; |
1329 |
+ |
ACTION_TRANS_COMMIT: |
1330 |
+ |
TriggerAction := taTransactionCommit; |
1331 |
+ |
ACTION_TRANS_ROLLBACK: |
1332 |
+ |
TriggerAction := taTransactionRollback; |
1333 |
+ |
ACTION_DDL: |
1334 |
+ |
TriggerAction := taDDL; |
1335 |
+ |
else |
1336 |
+ |
FBUDRError(ibxeUnknownTransactionAction,[action]); |
1337 |
+ |
end; |
1338 |
+ |
|
1339 |
|
case FRoutineMetadata.getTriggerType of |
1340 |
|
ttBefore: |
1341 |
|
begin |
1377 |
|
NewParamsSQLDA.Free; |
1378 |
|
if WritableParamsSQLDA <> nil then |
1379 |
|
WritableParamsSQLDA.Free; |
1380 |
+ |
FFirebirdAPI := nil; |
1381 |
|
end; |
1382 |
|
end; |
1383 |
|
except on E: Exception do |
1467 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1468 |
|
|
1469 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1470 |
+ |
{Now get the Field Names} |
1471 |
+ |
UpdateArgNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1472 |
|
if inBuilder <> nil then |
1473 |
|
FBInBuilder := TFBUDRMetadataBuilder.Create(FBContext,inBuilder); |
1474 |
|
if outBuilder <> nil then |
1490 |
|
try |
1491 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1492 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1466 |
– |
{Now get the Field Names} |
1467 |
– |
UpdateArgNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1493 |
|
Result := FProcedure.Create(FController,FName,FBRoutineMetadata, |
1494 |
|
FInArgNames,FOutArgNames); |
1495 |
|
except on E: Exception do |
1596 |
|
begin |
1597 |
|
try |
1598 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1599 |
< |
charset := getCharSet(FBContext); |
1600 |
< |
if charset <> '' then |
1601 |
< |
begin |
1602 |
< |
StrPLCopy(name,charset,nameSize); |
1603 |
< |
if loLogProcedures in FBUDRControllerOptions.LogOptions then |
1604 |
< |
FController.WriteToLog(Format(SProcCharset,[FName,charset])); |
1599 |
> |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
1600 |
> |
try |
1601 |
> |
charset := getCharSet(FBContext); |
1602 |
> |
if charset <> '' then |
1603 |
> |
begin |
1604 |
> |
StrPLCopy(name,charset,nameSize); |
1605 |
> |
if loLogProcedures in FBUDRControllerOptions.LogOptions then |
1606 |
> |
FController.WriteToLog(Format(SProcCharset,[FName,charset])); |
1607 |
> |
end; |
1608 |
> |
finally |
1609 |
> |
FFirebirdAPI := nil; |
1610 |
|
end; |
1611 |
|
except on E: Exception do |
1612 |
|
FController.FBSetStatusFromException(E,status); |
1760 |
|
begin |
1761 |
|
try |
1762 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1763 |
< |
charset := getCharSet(FBContext); |
1764 |
< |
if charset <> '' then |
1765 |
< |
begin |
1766 |
< |
StrPLCopy(name,charset,nameSize); |
1767 |
< |
if loLogFunctions in FBUDRControllerOptions.LogOptions then |
1768 |
< |
FController.WriteToLog(Format(SFuncCharset,[FName,charset])); |
1763 |
> |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
1764 |
> |
try |
1765 |
> |
charset := getCharSet(FBContext); |
1766 |
> |
if charset <> '' then |
1767 |
> |
begin |
1768 |
> |
StrPLCopy(name,charset,nameSize); |
1769 |
> |
if loLogFunctions in FBUDRControllerOptions.LogOptions then |
1770 |
> |
FController.WriteToLog(Format(SFuncCharset,[FName,charset])); |
1771 |
> |
end; |
1772 |
> |
finally |
1773 |
> |
FFirebirdAPI := nil; |
1774 |
|
end; |
1775 |
|
except on E: Exception do |
1776 |
|
FController.FBSetStatusFromException(E,status); |
1800 |
|
else |
1801 |
|
begin |
1802 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1803 |
+ |
FFirebirdAPI := FBContext.GetFirebirdAPI; |
1804 |
|
if [loLogFunctions,loDetails] <= FBUDRControllerOptions.LogOptions then |
1805 |
|
FController.WriteToLog((FBContext as TFBUDRExternalContext).AsText); |
1806 |
|
|
1850 |
|
OutParamsSQLDA.Free; |
1851 |
|
if InParamsSQLDA <> nil then |
1852 |
|
InParamsSQLDA.Free; |
1853 |
+ |
FFirebirdAPI := nil; |
1854 |
|
end; |
1855 |
|
end; |
1856 |
|
except on E: Exception do |
1926 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1927 |
|
|
1928 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1929 |
+ |
{Now get the argument Names} |
1930 |
+ |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1931 |
|
|
1932 |
|
if inBuilder <> nil then |
1933 |
|
FBInBuilder := TFBUDRMetadataBuilder.Create(FBContext,inBuilder); |
1951 |
|
try |
1952 |
|
FBContext := TFBUDRExternalContext.Create(Controller,context); |
1953 |
|
FBRoutineMetadata := TFBUDRRoutineMetadata.Create(FBContext,metadata); |
1915 |
– |
{Now get the argument Names} |
1916 |
– |
UpdateFieldNames(FBContext.GetAttachment,FBRoutineMetadata.getName); |
1954 |
|
Result := FFunction.Create(FController,FName,FBRoutineMetadata,FFieldNames); |
1955 |
|
except on E: Exception do |
1956 |
|
FController.FBSetStatusFromException(E,status); |