Bug in DML Array Insert

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
eml79
Posts: 13
Joined: Thu 28 Jun 2007 09:20

Bug in DML Array Insert

Post by eml79 » Tue 26 Apr 2011 09:41

when insert null in string field
TOraParamDesc.FLen reset in 0

Code: Select all

procedure TOraParamDesc.SetItemNull(Index: integer; Value: boolean);
var
  VPtr: IntPtr;
begin
  AllocBuffer;

  if Value then begin
    SetIndicator(Index, -1);
    FLen := 0;  // 1 this is a bug
Examle: insert 2 string via TOraSql (TOraSql.Params[0].Length := 2)
first string '1234567890' => TOraParamDesc.FLen = 10
second string is null => TOraParamDesc.FLen = 0

in TOCICommand.BindParam
BufferSize := Param.FLen + 1; FLen = 2000
2. after that insert 2 short string [call Execute(2)], max string len 20, but FLen before call is 2000, and not reset

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 27 Apr 2011 14:46

Hello,

Please provide the exact version of ODAC.

The Flen variable doesn't affect the final result even if it is set to 0, so please give a more detailed description of the problem.

The following sample code works fine, please modify it to reproduce the problem:

Code: Select all

 {
 create table testdmlarray
 (
 F_STR VARCHAR2(50)
 )
 }
  
  OraSQL1.SQL.Text :='INSERT INTO testdmlarray VALUES(:str)';
  OraSQL1.ParamByName('str').ParamType := ptInput;
  OraSQL1.ParamByName('str').DataType := ftString;
  OraSQL1.ParamByName('str').Length := 4;

  OraSQL1.Prepare;

  OraSQL1.ParamByName('str').ItemAsString[1] := '12345678901234567890';

  OraSQL1.ParamByName('str').ItemAsString[2] := '';

  OraSQL1.ParamByName('str').ItemAsString[3] := '1234567890';

  OraSQL1.ParamByName('str').ItemAsString[4] := '';

  OraSQL1.Execute(4);

eml79
Posts: 13
Joined: Thu 28 Jun 2007 09:20

Post by eml79 » Fri 20 May 2011 12:03

Code: Select all

  OraSQL1.ParamByName('str').ItemValue[1] := '12345678901234567890';
  OraSQL1.ParamByName('str').ItemValue[2] := '123456789012345';
  OraSQL1.ParamByName('str').ItemValue[3] := Null;
  OraSQL1.ParamByName('str').ItemValue[4] := '1234567890';
Result: ORA-01480

eml79
Posts: 13
Joined: Thu 28 Jun 2007 09:20

Post by eml79 » Fri 20 May 2011 12:26

Code: Select all

  OraSQL1.ParamByName('str').Length := 3;
  OraSQL1.Prepare;
  OraSQL1.ParamByName('str').ItemAsString[1] := '12345678901234567890';
  OraSQL1.ParamByName('str').ItemAsString[2] := '';
  OraSQL1.ParamByName('str').ItemAsString[3] := '1234567890';
  OraSQL1.Execute(3); 
Run OK, but in table
'1234567890' <---- !!!! instead of '12345678901234567890'
Null
'1234567890'

ODAC version 6.90.0.60

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 23 May 2011 06:29

Hello,

Thank you for the information.
We have reproduced the problem.
We will notify you as soon as we have any results.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 02 Jun 2011 09:21

Hello,

We have fixed the problem.
This fix will be included in the next build.

Post Reply