Page 1 of 1

Wrong length field value

Posted: Tue 20 Jul 2010 11:35
by dimon_adv
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).

Posted: Wed 21 Jul 2010 16:03
by rdeutsch
Have you set TOraSession.Options.ConvertEOL = true?

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

Posted: Fri 23 Jul 2010 08:14
by dimon_adv
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.

Posted: Fri 23 Jul 2010 14:33
by bork
Hello

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

Posted: Tue 27 Jul 2010 09:16
by bork
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).

Posted: Tue 27 Jul 2010 09:44
by dimon_adv
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'

Posted: Wed 28 Jul 2010 15:48
by bork
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.

Posted: Thu 29 Jul 2010 07:35
by dimon_adv
Thanks for information.