Subject | Parameter problems using DataSnap and IBO |
---|---|
Author | kokok_kokok |
Post date | 2004-01-15T22:05:26Z |
I use DataSnap with IBO. When I modify the id of a row, IBO does not
generate the appropriate parameters for the SQL sentence.
PRIMARY KEY of the table = EMPRESA, TIPUS, CODI
IBO generates the following sentence when I modify the CODI field:
UPDATE CODIFICATION SET EMPRESA = :EMPRESA , TIPUS = :TIPUS ,
CODI = :CODI , DESCRIPCIO = :DESCRIPCIO
WHERE CODIFICATION.EMPRESA = :OLD.EMPRESA AND CODIFICATION .TIPUS
= :OLD.TIPUS AND CODIFICATION.CODI = :OLD.COD
This sentence is fine. The problem is in parameters. If I modify
CODI, for example setting CODI=1, if before CODI was 0, I can see in
the SQL monitor:
[PARAMETERS]
CODI=0
OLD.CODI=0
It is an error, because CODI should be 1, not 0.
I have been tracing the IBODataset.pas source and I have found the
reason but not the solution.
1) PSUpdateRecord deletes the "OLD." prefix of the "OLD.CODI"
parameter name
2) Then , line 6593, function TIBODataSet.AssignParamsValues
if Assigned( Self.DataSource ) and Assigned(
Self.DataSource.Dataset ) then
if Assigned( Self.DataSource.Dataset.FindField(
tmpCol.FullFieldName )) then
Continue;
AssignParamValueToCol( AParams[ii], tmpCol );
tmpParam := FindParam( tmpCol.FullFieldName );
if Assigned( tmpParam ) then
tmpParam.Value := AParams[ii].Value;
end;
end;
end;
finally
The line "tmpParam := FindParam( tmpCol.FullFieldName );" cannot
find the corresponding parameter. It fails and it assigns the new
value to OLD.CODI because tmpCol.FullFieldName = "CODI",
not "OLD.CODI" (remember the previous PSUpdateRecord function)
Well, it is my diagnostic but I do not know the solution. Any help
well be welcome. Thanks
generate the appropriate parameters for the SQL sentence.
PRIMARY KEY of the table = EMPRESA, TIPUS, CODI
IBO generates the following sentence when I modify the CODI field:
UPDATE CODIFICATION SET EMPRESA = :EMPRESA , TIPUS = :TIPUS ,
CODI = :CODI , DESCRIPCIO = :DESCRIPCIO
WHERE CODIFICATION.EMPRESA = :OLD.EMPRESA AND CODIFICATION .TIPUS
= :OLD.TIPUS AND CODIFICATION.CODI = :OLD.COD
This sentence is fine. The problem is in parameters. If I modify
CODI, for example setting CODI=1, if before CODI was 0, I can see in
the SQL monitor:
[PARAMETERS]
CODI=0
OLD.CODI=0
It is an error, because CODI should be 1, not 0.
I have been tracing the IBODataset.pas source and I have found the
reason but not the solution.
1) PSUpdateRecord deletes the "OLD." prefix of the "OLD.CODI"
parameter name
2) Then , line 6593, function TIBODataSet.AssignParamsValues
if Assigned( Self.DataSource ) and Assigned(
Self.DataSource.Dataset ) then
if Assigned( Self.DataSource.Dataset.FindField(
tmpCol.FullFieldName )) then
Continue;
AssignParamValueToCol( AParams[ii], tmpCol );
tmpParam := FindParam( tmpCol.FullFieldName );
if Assigned( tmpParam ) then
tmpParam.Value := AParams[ii].Value;
end;
end;
end;
finally
The line "tmpParam := FindParam( tmpCol.FullFieldName );" cannot
find the corresponding parameter. It fails and it assigns the new
value to OLD.CODI because tmpCol.FullFieldName = "CODI",
not "OLD.CODI" (remember the previous PSUpdateRecord function)
Well, it is my diagnostic but I do not know the solution. Any help
well be welcome. Thanks