Je to kontrola údajov na jedinečnosť/unique. Pred vyvolaním Post. Alebo mi navrhnite iné riešenie.
Mám nasledujúcu funkciu pre FireDAC. Teraz to potrebujem pre IBCDAC.
function TjstIBCNavigator.CompositeUniqueIndexOK: Boolean;
const Prefix = 'UQ_';
var
Fields, sSelect: string;
I, Idx: Integer;
begin
var lstField := TStringList.Create;
var Qry := TIBCQuery.Create(nil);
Qry.Connection := FIBCTable.Connection; Qry.Transaction := FIBCTable.Transaction;
l
try
for var FDIndex := 0 to FIBCTable.Indexes.Count - 1 do
begin
if Copy(FIBCTable.Indexes[FDIndex].Name, 1, Length(Prefix)) = Prefix then
begin
Fields := FIBCTable.Indexes[FDIndex].Fields;
Idx := FindDelimiter(';', Fields, 1);
if Idx = 0 then Continue;
l
QryText(Idx, Fields, sSelect, lstField);
Qry.SQL.Text := sSelect;
l
for I := 0 to lstField.Count - 1 do
Qry.ParamByName(lstField[I]).Value := FIBCTable.FieldByName(lstField[I]).Value;
l
if FIBCTable.State = dsEdit then
Qry.ParamByName('PRIMARYKEY').AsInteger := FIBCTable.Fields.Fields[0].AsInteger;
l
if Qry.Active then
Qry.Refresh
else
Qry.Open;
l
if not Qry.IsEmpty then
begin
var UniqueDialog := TFaultUniqueDialog.Create(FDataSource.DataSet, FPrmIDFoc, FPrmCurrentYear);
UniqueDialog.ShowFaultDialog(Serpar_AnalSerPeriod);
Exit(False);
end;
end;
end;
finally
Qry.Free;
lstField.Free;
end;
l
Result := True;
end;
No FIBCTable nepozná Indexes. Nepodarilo sa mi k tomu nič nájsť.