Bug of parameter of type AsArray.

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Mic777
Posts: 4
Joined: Mon 11 Aug 2008 09:27

Bug of parameter of type AsArray.

Post by Mic777 » Mon 11 Aug 2008 12:03

Hello.

In Oracle objects are created:

Code: Select all

create or replace
  type FoundESNRecord AS OBJECT (
    ID_ESNI  INTEGER,
    VData   varchar2(2000))

create or replace
  type FoundESNIdTable AS TABLE OF FoundESNRecord
In Delphi the form on which are placed TButton, TOraSession, TOraQuery is created.

In handler events OnClick of object TButton the code contains:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var IndexRecord,
    IndexArray: integer;
begin
  TempQuery.Close;
  TempQuery.SQL.Text := 'Select * ' +
    'From table( cast( :p_FoundESNIdTable as FoundESNIdTable ))';
  TempQuery.ParamByName( 'p_FoundESNIdTable' ).AsArray.AllocObject(TempQuery.Session.OCISvcCtx, 'FoundESNIdTable');

  with TempQuery.ParamByName( 'p_FoundESNIdTable' ).AsArray do
  begin
    for IndexRecord := 1 to 10 do
    begin
      IndexArray := AppendItem;
      ItemAsObject[IndexArray].AttrAsLargeInt[ 'ID_ESNI' ] := IndexRecord;
    end;
  end;
  TempQuery.Open;
  ShowMessage('RecordCount: ' + inttostr(TempQuery.RecordCount) );
end;
By the first pressing the button I receive the message
" RecordCount: 0 ".
At the subsequent - RecordCount: 10 (as well as should be).

It is a bug or I do something incorrectly?

It is shown up for versions ODAC 6.50.0.35 and 6.50.0.36.

Best regards.
Michael.

Mic777
Posts: 4
Joined: Mon 11 Aug 2008 09:27

As yet I have solved the given problem so...

Post by Mic777 » Tue 12 Aug 2008 08:06

Code: Select all

TempQuery.Close;
TempQuery.SQL.Text := 'Select * ' +
  'From table( cast( :p_FoundESNIdTable as FoundESNIdTable ))';  TempQuery.ParamByName( 'p_FoundESNIdTable' ).AsTable.AllocObject(TempQuery.Session.OCISvcCtx, 'FoundESNIdTable');

TempQuery.SQL.Text := TempQuery.SQL.Text; // !!! I redefine the text of inquiry and that's all there's to it.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 12 Aug 2008 12:37

We have fixed this problem. The fix will be included in the next build of ODAC.

The problem is in the IsNull property of the parameter. As a workaround you can use the following code to make the IsNull property False:

Code: Select all

TempQuery.ParamByName( 'p_FoundESNIdTable' ).Value := 'A';

Post Reply