Page 1 of 1

Error in executing select query with cursor

Posted: Tue 12 Mar 2019 12:42
by dqrest
Hello!

I use MS VS 2017 and C#.
I have dotConnect for Oracle 6.2 and the following tables:

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
);
I'd like to read data from db by executing query with cursors.
For example:

Code: Select all

DataSet dataSet = new DataSet();
string sql = "SELECT dept.*, CURSOR(SELECT * FROM emp WHERE emp.DeptNo = Dept.DeptNo) AS Emp FROM dept";
using (OracleCommand oraCommand = new OracleCommand(sql, Entry.Connection))
{
     OracleDataAdapter oraDataAdapter = new OracleDataAdapter();
     oraDataAdapter.SelectCommand = oraCommand;
      //oraDataAdapter.Container.Components.
      oraDataAdapter.Fill(dataSet, "Dept");
}
After calling the "Fill" method it is occured the error "DataSet Columns of hierarchical chapters must be mapped to a DataColumn with the AutoIncrement property". How can I fix this problem?

Re: Error in executing select query with cursor

Posted: Tue 12 Mar 2019 12:46
by dqrest
Moreover, I follow the post https://www.devart.com/dotconnect/oracl ... rsors.html to read data with cursors.

Re: Error in executing select query with cursor

Posted: Wed 13 Mar 2019 11:42
by dqrest
Any ideas? Should I wait for the answear for my problem?

Re: Error in executing select query with cursor

Posted: Wed 13 Mar 2019 13:55
by Pinturiccio
dqrest wrote:I have dotConnect for Oracle 6.2
There is no such version of dotConnect for Oracle. Specify the full version of the provider. Please also try using the latest dotConnect for Oracle 9.6.696. You can download the trial version of dotConnect for Oracle from our site https://www.devart.com/dotconnect/oracle/download.html

We could not reproduce the issue with the latest dotConnect for Oracle 9.6.696.

Re: Error in executing select query with cursor

Posted: Thu 14 Mar 2019 05:26
by dqrest
Pinturiccio wrote: Wed 13 Mar 2019 13:55 There is no such version of dotConnect for Oracle. Specify the full version of the provider.
Excuse me, I use dotConnect for Oracle 6.60.258. I note that it is not possible to use the newest version of dotConnect in the software, because it is used mapping of nullable values in the primary key fields of classes. For example, there are errors in the newest version

Code: Select all

public class A
{
   [Column(Name = "SPACE_NO", IsPrimaryKey = true)]
    public int? Id {get; set;}
}.
If it is possible to avoid these problem, tell me how to do it.

Re: Error in executing select query with cursor

Posted: Thu 14 Mar 2019 18:33
by Shalex
dqrest wrote: Tue 12 Mar 2019 12:42 Hello!

I use MS VS 2017 and C#.
I have dotConnect for Oracle 6.2 and the following tables:

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
);
I'd like to read data from db by executing query with cursors.
For example:

Code: Select all

DataSet dataSet = new DataSet();
string sql = "SELECT dept.*, CURSOR(SELECT * FROM emp WHERE emp.DeptNo = Dept.DeptNo) AS Emp FROM dept";
using (OracleCommand oraCommand = new OracleCommand(sql, Entry.Connection))
{
     OracleDataAdapter oraDataAdapter = new OracleDataAdapter();
     oraDataAdapter.SelectCommand = oraCommand;
      //oraDataAdapter.Container.Components.
      oraDataAdapter.Fill(dataSet, "Dept");
}
After calling the "Fill" method it is occured the error "DataSet Columns of hierarchical chapters must be mapped to a DataColumn with the AutoIncrement property". How can I fix this problem?
v6.60.258 fails with the error, v9.6.696 works OK using your code.
dqrest wrote: Thu 14 Mar 2019 05:26I note that it is not possible to use the newest version of dotConnect in the software, because it is used mapping of nullable values in the primary key fields of classes. For example, there are errors in the newest version

Code: Select all

public class A
{
   [Column(Name = "SPACE_NO", IsPrimaryKey = true)]
    public int? Id {get; set;}
}.
If it is possible to avoid these problem, tell me how to do it.
Please send us a test project so that we can reproduce the generation of nullable type for the primary key property. Entity Developer should disable the Nullable option in the designer when Entity Key is selected.