Page 1 of 1

LargeInt and Object tables

Posted: Fri 14 Mar 2014 07:59
by m.ghilardi
Let's say I have an object table like this

Code: Select all

create type my_type as object(
	a_id number(18),
	a_name varchar2(160 char)
);
create table my_table of my_type; 
With this values inserted:

Code: Select all

insert into my_table values (999999999999999999,'value1');
insert into my_table values (9007199254740992,'value2');
Create a simple TOraQuery (MyQuery) with this SQL statement:

Code: Select all

select value(x) obj, x.a_id id from my_table x order by id
in the TOraSession I have enableintegers=true, enablelargeint=true.

Code: Select all

MyQuery->Open();

__int64 int1 = MyQuery->FieldByName(L"obj.a_id")->AsLargeInt;
__int64 int2 = MyQuery->FieldByName(L"id")->AsLargeInt;
MyQuery->Next();
__int64 int3 = MyQuery->FieldByName(L"obj.a_id")->AsLargeInt;
__int64 int4 = MyQuery->FieldByName(L"id")->AsLargeInt;
The Result is

int1 9007199254740992 int2 9007199254740992 int3 999999999999999872 int4 999999999999999999

2^53=9007199254740992 is the biggest integer that can be stored in a double.

Re: LargeInt and Object tables

Posted: Fri 14 Mar 2014 09:37
by AlexP
Hello,

We cannot reproduce the problem. Please try to reproduce the problem on the latest ODAC version 9.2.7

Re: LargeInt and Object tables

Posted: Fri 14 Mar 2014 11:29
by m.ghilardi
Hello,
I was able to reproduce the problem using ODAC 9.2.7.

Rad Studio XE4
Oracle 11g Express

Execute this SQL script using sqlplus

Code: Select all

create type my_type as object(
	a_id number(18),
	a_name varchar2(160 char)
);

create table my_table of my_type; 

insert into my_table values (999999999999999999,'value1');
insert into my_table values (9007199254740992,'value2');
Create a new C++ VCL project. Only one form is needed.

Unit1.h

Code: Select all

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include "DBAccess.hpp"
#include "MemDS.hpp"
#include "Ora.hpp"
#include "OraCall.hpp"
#include <Data.DB.hpp>
#include <Vcl.DBGrids.hpp>
#include <Vcl.Grids.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TOraSession *OraSession1;
	TOraQuery *OraQuery1;
	TMemo *Memo1;
	void __fastcall FormShow(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit1.cpp

Code: Select all

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "DBAccess"
#pragma link "MemDS"
#pragma link "Ora"
#pragma link "OraCall"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
	OraQuery1->Open();
	OraQuery1->Open();

	__int64 int1 = OraQuery1->FieldByName(L"obj.a_id")->AsLargeInt;
	__int64 int2 = OraQuery1->FieldByName(L"id")->AsLargeInt;
	OraQuery1->Next();
	__int64 int3 = OraQuery1->FieldByName(L"obj.a_id")->AsLargeInt;
	__int64 int4 = OraQuery1->FieldByName(L"id")->AsLargeInt;

	Memo1->Lines->Add(UnicodeString().sprintf(L"int1 %Ld",int1));
	Memo1->Lines->Add(UnicodeString().sprintf(L"int2 %Ld",int2));
	Memo1->Lines->Add(UnicodeString().sprintf(L"int3 %Ld",int3));
	Memo1->Lines->Add(UnicodeString().sprintf(L"int4 %Ld",int4));
}
//---------------------------------------------------------------------------
Unit1.dfm

Code: Select all

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 279
  ClientWidth = 475
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Memo1: TMemo
    Left = 96
    Top = 8
    Width = 185
    Height = 89
    TabOrder = 0
  end
  object OraSession1: TOraSession
    Options.EnableLargeint = True
    Options.EnableNumbers = True
    Left = 360
    Top = 72
  end
  object OraQuery1: TOraQuery
    Session = OraSession1
    SQL.Strings = (
      'select value(x) obj, x.a_id id from my_table x order by id')
    Left = 160
    Top = 40
  end
end

Re: LargeInt and Object tables

Posted: Wed 07 May 2014 12:19
by AlexP
This behavior is due to the fact that these options (EnableLargeint, EnableNumbers) are not applied to object attributes (fields). We will consider the possibility to change this behavior in the future.

Re: LargeInt and Object tables

Posted: Wed 17 Sep 2014 07:27
by m.ghilardi
Has this feature been implemented in ODAC 9.4? Is this planned for the near future?
Sorry for bumping this, but I use a lot of Objects in my project, and I was forced to limit the size of Integers on DB because of this limitation in the client.

Re: LargeInt and Object tables

Posted: Wed 17 Sep 2014 10:09
by AlexP
No, this feature is not yet implemented. We have added it to our roadmap, however, we cannot say the exact timing of its implementation.