SmartQuery with MasterSource and empty detail dataset crash

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Petriukx
Posts: 12
Joined: Tue 06 Jun 2006 11:17

SmartQuery with MasterSource and empty detail dataset crash

Post by Petriukx » Thu 12 May 2011 05:44

Hi

I have a really nasty problem. My application build with Delphi 7 and ODAC 7.00.0.3 crashes when main query becomes empty after opening it. Message some kind of read address from ????.

I can't reproduce it in simple application, but I think that the problem is when:

SmartQuery1 (MainQuery)
DataSource1 (DataSet=MainQuery)
SmartQuery2 (SubQuery, SubQuery.MasterSource=DataSource1)

when MainQuery has data then SubQuery execute 1 SQL statement (saw via OraMonitor)
when MainQuery is empty then SubQuery execute 2 same SQL statements with null params (saw via OraMonitor).

so if there are more than 2 Queries, and they are more complicated, and have own SubQueries (and some events on after scroll), and cxGrid (more afterscroll events) it can be harmful...

The question is why on empty MainQuery SubQuery via MasterSource opened twice and can it be fixed?

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

Post by AlexP » Thu 12 May 2011 08:21

Hello,

I could not reproduce the problem.

I have tested this problem in the following way:

Code: Select all

  CREATE TABLE DEPT (
  DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY,
  DNAME VARCHAR2(14) ,
  LOC VARCHAR2(13)
);

CREATE TABLE EMP (
  EMPNO NUMBER(4) CONSTRAINT PK_EMP PRIMARY KEY,
  ENAME VARCHAR2(10),
  JOB VARCHAR2(9),
  MGR NUMBER(4),
  HIREDATE DATE,
  SAL NUMBER(7,2),
  COMM NUMBER(7,2),
  DEPTNO NUMBER(2) CONSTRAINT FK_DEPTNO REFERENCES DEPT
);

Code: Select all

  MainQuery:= TSmartQuery.Create(nil);
  MainQuery.Session := OraSession1;
  MainQuery.SQL.Text := 'select * from dept where deptno = :deptno';
  MainQuery.ParamByName('deptno').DataType := ftInteger;
  MainQuery.ParamByName('deptno').ParamType := ptInput;

  SubQuery:= TSmartQuery.Create(nil);
  SubQuery.Session := OraSession1;
  SubQuery.SQL.Text := 'select * from emp';

  MainDataSource:= TOraDataSource.Create(nil);
  MainDataSource.DataSet := MainQuery;

  SubQuery.MasterSource := MainDataSource;
  SubQuery.MasterFields := 'DEPTNO';
  SubQuery.DetailFields := 'DEPTNO';

  MainQuery.ParamByName('deptno').AsInteger := -1; //value doesn't exists
  MainQuery.Open;
  SubQuery.Open;
and in DBMonitor I can see only one query even if MainQuery is empty.

So please send a complete sample to alexp*devart*com to demonstrate the problem including a script to create and fill tables.

Post Reply