problem with TZStoredProc

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
emils
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 08.09.2008, 10:33

problem with TZStoredProc

Post by emils »

Hi everyone,

I am usеing ZEOSDBO-6.6.6-stable.
I am trying to set a param of TZStoredProc with this code:

TZStoredProc.ParamByName('MyDATE').asString:= '';

this generates Conversion error. In the firebird stored procedure, parameter 'MyDate' is of type Timestamp. The same problem i have with integers too.

any ideas?
thanks!
emils
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 08.09.2008, 10:33

solved partially ...

Post by emils »

I thing the problem is in procedure TZAbstractRODataset.SetStatementParams, specially this part:

Code: Select all

if Param.IsNull then begin
         Statement.SetNull(I + 1, ConvertDatasetToDbcType(Param.DataType))
      end else begin
        case Param.DataType of
          ftBoolean:
            Statement.SetBoolean(I + 1, Param.AsBoolean);
          ftSmallInt:
            Statement.SetShort(I + 1, Param.AsSmallInt);
          ftInteger, ftAutoInc:
            Statement.SetInt(I + 1, Param.AsInteger);
................
i thing that looking for cases of Param.Datatype undermines useing type conversions like:
ParamByName(Integer Parameter).asString ...
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

What date do you expect from TZStoredProc.ParamByName('MyDATE').asString:= '';
???
I suppose the right action is setting a null parameter.

Mark
Image
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

TZStoredProc.ParamByName('MyDATE').asString:= '' behaves correctly - it raises conversion error because empty string can't be converted into date (and empty str is not null either).
For NULLs , there is Clear method e.g. TZStoredProc.ParamByName('MyDATE').Clear
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

trupka,

Thanks for your intervention. That was indeed the message I wanted to pass, but your way of explaining it is way more helpfull.

Mark
Image
Post Reply