Subject | TIBOQuery wrong Params datatype on insert |
---|---|
Author | henry FRANQUET |
Post date | 2003-11-26T17:28:03Z |
Hi
I have a TIBOQuery insert statement with parameterized fields and I
get wrong parameter's datatype on execute
for example a Query like
insert into TBL1 (FLD1, FLD2, FLD3, FLD4, FLD5)
select :pfld1, TBL2.FLD, :pfld3, :pfld4, :pfld5
from RDB$DATABASE, TBL2
where TBL2.KEY1 = :pfld2
with pfld1, pfld4 assigned as string and pfld5 assigned as DateTime
I have an error message 'XXX4' is not a valid DATE... where 'XXX4'
is the value assigned
to pfld4. It seems that the parameter's type migrate from one to other
my coding looks like
Qry.Close
for i := 0 to Qry.Params.Count - 1 do Qry.Params[i].Clear;
if not Qry.Prepared then Qry.Prepare
Qry.Params.ParamByName('pfld1').AsString := 'XXX1'
Qry.Params.ParamByName('pfld2').AsString := 'XXX2'
Qry.Params.ParamByName('pfld3').AsString := 'XXX3'
Qry.Params.ParamByName('pfld4').AsString := 'XXX4'
Qry.Params.ParamByName('pfld5').DateTime :=
StrToDateTime('01/01/2000')
try
Qry.ExecSQL
except
...
I use Delphi5 with IBO4.2 I f TEST
when looking Qry.Params before executing the query all is fine :
pfld4 is a string and pfld5 is a DateTime and values are correct
when executing, I got ERRCODE 335544569 (DSQL Error) on IBMonitor
and the above error message
in IBMonitor :pfld5 param's value shows as '01/01' but perhaps it is
only a displaying error in IBMonitor
of course when executing 2 sql statements :
select FLD from TBL2 where KEY1 = :pfld6
and then
insert into TBL1 (FLD1, FLD2, FLD3, FLD4, FLD5)
values( :pfld1, :pfld2, :pfld3, :pfld4, :pfld5)
all is fine
Is there a workaround to force execsql not to reassign parameter's type
Thanks a lot
I have a TIBOQuery insert statement with parameterized fields and I
get wrong parameter's datatype on execute
for example a Query like
insert into TBL1 (FLD1, FLD2, FLD3, FLD4, FLD5)
select :pfld1, TBL2.FLD, :pfld3, :pfld4, :pfld5
from RDB$DATABASE, TBL2
where TBL2.KEY1 = :pfld2
with pfld1, pfld4 assigned as string and pfld5 assigned as DateTime
I have an error message 'XXX4' is not a valid DATE... where 'XXX4'
is the value assigned
to pfld4. It seems that the parameter's type migrate from one to other
my coding looks like
Qry.Close
for i := 0 to Qry.Params.Count - 1 do Qry.Params[i].Clear;
if not Qry.Prepared then Qry.Prepare
Qry.Params.ParamByName('pfld1').AsString := 'XXX1'
Qry.Params.ParamByName('pfld2').AsString := 'XXX2'
Qry.Params.ParamByName('pfld3').AsString := 'XXX3'
Qry.Params.ParamByName('pfld4').AsString := 'XXX4'
Qry.Params.ParamByName('pfld5').DateTime :=
StrToDateTime('01/01/2000')
try
Qry.ExecSQL
except
...
I use Delphi5 with IBO4.2 I f TEST
when looking Qry.Params before executing the query all is fine :
pfld4 is a string and pfld5 is a DateTime and values are correct
when executing, I got ERRCODE 335544569 (DSQL Error) on IBMonitor
and the above error message
in IBMonitor :pfld5 param's value shows as '01/01' but perhaps it is
only a displaying error in IBMonitor
of course when executing 2 sql statements :
select FLD from TBL2 where KEY1 = :pfld6
and then
insert into TBL1 (FLD1, FLD2, FLD3, FLD4, FLD5)
values( :pfld1, :pfld2, :pfld3, :pfld4, :pfld5)
all is fine
Is there a workaround to force execsql not to reassign parameter's type
Thanks a lot