Wrong length field value

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dimon_adv
Posts: 27
Joined: Mon 01 Feb 2010 09:36

Wrong length field value

Post by dimon_adv » Tue 20 Jul 2010 11:35

In my application i query value from XDB database as Tbytes and if size resource (XML files) is small (< 4000) value have wrong size (=4000). Why ?

Select:

Code: Select all

  TmpQuery.SQL.Text := 'select DBMS_XDB.GETCONTENTCLOB(:P_Path) RES FROM DUAL';
Parameter value like as '/public/TemplatesForDelivery/Formula_2647.xml'

Value assigment:

Code: Select all

Result := TmpQuery.FieldByName('RES').AsBytes;
FileSize in XDB = 301 bytes
Length(Result) = 4000 bytes
Why ?

P.S. Delphi2010, Odac 6.90.0.58, Oracle 11gr2 (Win x64).

rdeutsch
Posts: 13
Joined: Mon 16 Apr 2007 09:29

Post by rdeutsch » Wed 21 Jul 2010 16:03

Have you set TOraSession.Options.ConvertEOL = true?

Take a look:
http://www.devart.com/forums/viewtopic.php?t=18529

dimon_adv
Posts: 27
Joined: Mon 01 Feb 2010 09:36

Post by dimon_adv » Fri 23 Jul 2010 08:14

After set this option return size of field wrong too...
I change SQL for this:
select res, length(res) lres from (select DBMs_xdb.getContentClob(:P_Path) res from dual)

ConvertEOL = False
TmpQuery.FieldByName('LRES').AsLargeInt = 131
Length(TmpQuery.FieldByName('RES').AsBytes) = 4000

ConvertEOL = True !
TmpQuery.FieldByName('LRES').AsLargeInt = 131
Length(TmpQuery.FieldByName('RES').AsBytes) = 4005 !!!

In my code i use:
Result := TmpQuery.FieldByName('RES').AsBytes;
SetLength(Result, TmpQuery.FieldByName('LRES').AsLargeInt);

But this is a workaround solution to the problem and not the expected behavior of components.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Fri 23 Jul 2010 14:33

Hello

We are investigating your issue. We will notify you as soon as we have any result.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 27 Jul 2010 09:16

I cannot reproduce your issue. Please try to reproduce your issue in a new empty application. Create a new application, add a new button and add the following code on the button click event:

Code: Select all

var
  i: integer;
  MySession: TOraSession;
  MyQuery: TOraQuery;
  str: string;
begin
  MySession := TOraSession.Create(self);
  MySession.Server := 'ORA1110';
  MySession.Password := 'tiger';
  MySession.Username := 'scott';

  try
    MySession.ExecSQL('begin ' + #13 +
                      'DBMS_XDB.DeleteResource(''/public/test_README.txt''); ' + #13 +
                      'commit; ' + #13 +
                      'end;', []);
  except
  end;

  MySession.ExecSQL('declare  ' + #13 +
                    'res BOOLEAN; ' + #13 +
                    'begin ' + #13 +
                    'res := DBMS_XDB.createResource(''/public/test_README.txt'', ''This folder lists all of the US customer who are important to our business''); ' + #13 +
                    'commit; ' + #13 +
                    'end;', []);

  MyQuery := TOraQuery.Create(self);
  MyQuery.Session := MySession;
  MyQuery.SQL.Text := 'select DBMS_XDB.GETCONTENTCLOB(''/public/test_README.txt'') RES FROM DUAL';
  MyQuery.Open;

  str := MyQuery.FieldByName('res').AsString;
  ShowMessage(str + #13 + 'Length: ' + IntToStr(Length(str)));
end;
I got the result:
This folder lists all of the US customer who are important to our business
Length: 74
Please provide me the result of executing this code. If this code is working correctly then please modify this code to reproduce your issue.

Also please provide us the exact ODAC version that you are using (for example 6.90.0.59).

dimon_adv
Posts: 27
Joined: Mon 01 Feb 2010 09:36

Post by dimon_adv » Tue 27 Jul 2010 09:44

Length = 4000
In my first post -> ODAC = 6.90.0.58


'This folder lists all of the US customer who are important to our business'#0#0#0#0#0.........#0#0#0#0#0$D'Length: 4000'

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 28 Jul 2010 15:48

Hello

We have reproduced this issue. In the Oracle 11.2 the OCIAttrGet2 method return invalid column length for query:

Code: Select all

select DBMS_XDB.GETCONTENTCLOB(''/public/test_README.txt'') RES FROM DUAL
In the Oracle 11.1 this function returns correct value. It seems like this is an Oracle bug and we cannot fix it. You can ask Oracle support to fix this bug.

dimon_adv
Posts: 27
Joined: Mon 01 Feb 2010 09:36

Post by dimon_adv » Thu 29 Jul 2010 07:35

Thanks for information.

Post Reply