TOraQuery: Access Violation on Refresh.

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

TOraQuery: Access Violation on Refresh.

Post by m.ghilardi » Thu 27 Mar 2014 11:32

Tested in ODAC 9.2.7
I noticed that in previous versions of ODAC (9.1.4 for example) this happened very randomly, while in the latest release is quite frequent.

This happens only when I use object tables.

create an object type and a table:

Code: Select all

create or replace type obj1 as object
(
  a_id number(18),
  member procedure f_delete  
);

create table table1 of obj1;

create or replace type body obj1 as
  member procedure f_delete is
  begin
    delete from table1 x where x.a_id = self.a_id;
  end;
end;

insert into table1 values(1);
insert into table1 values(2);
insert into table1 values(3);
insert into table1 values(4);
insert into table1 values(5);
Then create a form where you can delete objects from the table and refresh the OraQuery.

Unit1.dfm

Code: Select all

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 279
  ClientWidth = 373
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object DBGrid1: TDBGrid
    Left = 8
    Top = 8
    Width = 281
    Height = 265
    DataSource = OraDataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'Tahoma'
    TitleFont.Style = []
  end
  object Button1: TButton
    Left = 295
    Top = 39
    Width = 75
    Height = 25
    Caption = 'Delete'
    TabOrder = 1
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 295
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Connect'
    TabOrder = 2
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 295
    Top = 70
    Width = 75
    Height = 25
    Caption = 'Refresh'
    TabOrder = 3
    OnClick = Button3Click
  end
  object OraQuery1: TOraQuery
    SQLDelete.Strings = (
      'declare'
      'ob1 obj1;'
      'begin'
      'ob1:=:obj;'
      'ob1.f_delete;'
      'end;')
    SQL.Strings = (
      'select value(x) obj from table1 x')
    AutoCommit = False
    ObjectView = True
    Left = 280
    Top = 112
  end
  object OraDataSource1: TOraDataSource
    DataSet = OraQuery1
    Left = 208
    Top = 184
  end
  object OraSession1: TOraSession
    AutoCommit = False
    Left = 208
    Top = 112
  end
end
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
	TOraQuery *OraQuery1;
	TDBGrid *DBGrid1;
	TButton *Button1;
	TOraDataSource *OraDataSource1;
	TOraSession *OraSession1;
	TButton *Button2;
	TButton *Button3;
	void __fastcall Button1Click(TObject *Sender);
	void __fastcall Button2Click(TObject *Sender);
	void __fastcall Button3Click(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::Button1Click(TObject *Sender)
{
	OraQuery1->Delete();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
	if(!OraSession1->Connected)
	{
		OraSession1->Username=L"user";
		OraSession1->Password=L"pass";
		OraSession1->Server=L"server";
		OraSession1->Connect();
		OraQuery1->Open();
	}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
	OraQuery1->Refresh();
}
//---------------------------------------------------------------------------
When the application is launched, click Connect, then Delete, and Refresh.
The message I get is:

Code: Select all

---------------------------
Bugrefresh
---------------------------
Access violation at address 0068F361 in module 'dac180.bpl'. Read of address FFFFFFFC.
---------------------------
OK   
---------------------------

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

Re: TOraQuery: Access Violation on Refresh.

Post by AlexP » Fri 28 Mar 2014 09:29

Hello,

We have reproduced the problem and will investigate the reasons for such behavior.

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: TOraQuery: Access Violation on Refresh.

Post by m.ghilardi » Fri 28 Mar 2014 09:56

I have found that replacing Refresh() with Close(), Open() is quite an effective workaround. I couldn't reproduce it in a controlled environment, but in one case even a Delete() call raised Access Violation: I had to delete the record using a script, then Close()/Open() the query.

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

Re: TOraQuery: Access Violation on Refresh.

Post by AlexP » Wed 07 May 2014 11:19

We have already fixed this proble. The new version with this fix is already available for download at our website.

Post Reply