Problem when setting param's length

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
odac9pro
Posts: 14
Joined: Wed 16 Apr 2014 11:01

Problem when setting param's length

Post by odac9pro » Mon 27 Mar 2017 12:33

Have a TOraStoredProc component, which is calls a function with a "TABLE OF NUMBER" param.
When I try to set the param's length in to 3 it jumpes to 4. The code changing the param's length in a cycle, multiple times,
We recently upgraded both IDE and ODAC, our code was working under XE3-ODAC pro 8.6.11, but not working under XE7-ODAC pro 9.6.20.

Code: Select all

  // oracle datatype:
  // TYPE t_table_of_number IS TABLE OF NUMBER INDEX BY PLS_INTEGER;

  for i:= 1 to 5 do
  begin
    stoDemoSP.ParamByName('i_table_ids').Length := i;
    // here is the anomaly, i = 3, but stoDemoSP.ParamByName('i_table_ids').Length jumpes to 4
    stoDemoSP.ParamByName('i_table_ids').ItemValue[i] := (i * i);
  end;
UPDATE: Investigated further, it looks like the problem caused when the VarArray created (or redimensioned), the ODAC's code mixing the zero and the 1 based indexes.

i <= 1
FDataPtr := [param_value] > 1 item
i = 2
FDataPtr := VarArrayCreate([0, 1], varVariant); [0..1] > 2 items
i >= 3
VarArrayRedim(FDataPtr, [param_length]); > [0..3] > 4 items!

should be

Code: Select all

  FDataPtr := VarArrayCreate([1, 2], varVariant); [1..2] > 2 items
  VarArrayRedim(FDataPtr, [param_length]); > [1..3] > 3 items
or

Code: Select all

  FDataPtr := VarArrayCreate([0, 1], varVariant); [0..1] > 2 items
  VarArrayRedim(FDataPtr, [param_length - 1]); > [0..2] > 3 items

odac9pro
Posts: 14
Joined: Wed 16 Apr 2014 11:01

Re: Problem when setting param's length

Post by odac9pro » Wed 29 Mar 2017 12:17

Upgraded to ODAC Pro 9.7.28, same bug.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Problem when setting param's length

Post by MaximG » Thu 30 Mar 2017 10:59

Thank you for the information. We reproduced the problem and fixed this error. The fix will be included in ODAC next build.

Post Reply