I have a problem when opening a TUniQuery.
This Query has 3 parameters that the TUniQuery detect (PAramCheck := true).
But when I passes values to each param with a managed function, I passe a third param with name that not exists on the ParamList Query.
I modify the 3rd param dynamically and I open the Query.
Here an Exception is raised: ORA 1036
this is an exemple :
Code: Select all
//....
function fAddParameter(var poQuery: TUniQuery; psName: String; poDataType: TFieldType; pvValue: Variant): boolean;
var
LengthValue: Integer;
Index, I: Integer;
pParam: TParam;
begin
Result := False;
poQuery.ParamCheck := False;
index := -1;
pParam := nil;
if psName = '' then
Exit;
if IsEmptyOrNull( pvValue ) then
pvValue := NULL;
for I := 0 to poQuery.ParamCount-1 do
begin
if (poQuery.FindParam(psName) = nil) and (IsEmptyOrNull(poQuery.Params[I].Value)) then
begin
index := I;
Break;
end;
end;
if (poQuery.FindParam(psName) = nil) and index <> -1 then
begin
poQuery.Params.Delete(index);
pParam := poQuery.Params.AddParameter;
pParam.index := Index;
pParam.Name := psName;
poQuery.Params.AddParam(pParam);
end
poQuery.ParamByName(psName).ParamType := ptInput;
poQuery.ParamByName(psName).DataType := poDataType;
poQuery.ParamByName(psName).Value := pvValue;
Result := True;
end;
//....
procedure TForm6.Button1Click(Sender: TObject);
begin
qrSQL.Close;
{ // SQL text.
SELECT * FROM TIERS
WHERE TIERS_FORMJ_ID = :jID
AND TIERS_LANGU_ID = :gID
AND TIERS_SCGEO_ID = :sID
}
qrSQL.SQL.Clear;
qrSQL.SQL.Text := mmSQL.Text ;
//mmRES.Lines.Add( IntToStr (qrSQL.ParamCount) );
fAddParameter( qrSQL, 'jID' , ftInteger, 1817 );
fAddParameter( qrSQL, 'gID' , ftInteger, 1 );
fAddParameter( qrSQL, 'x3' , ftInteger, 1 );
qrSQL.Open;
pAddToMemo(mmRES, '-------------------------------------------------------------');
end;
It Change the paramName by raises an ORA-1036.
Please Help.