I have an OleDBCommand which queries an Oracle table to retrieve courses and in the where clause of the command, I have specified a list as one of the conditions. This list is derived from an entirely different source and looks like this (I have included on the part of the code that's relevant);
string coursereferencesList = "(" + "\'" + string.Join("\', \'", courseRefsFromOtherSource.ToArray()) + "\'" + ")";
cmd.CommandText="SELECT course.Reference as courseref, course.name as coursename, department.Name as department from COURSE_TABLE course JOIN DEPARTMENT_TABLE department ON course.ID=department.COURSE " +
"WHERE course.TYPE ='Module' and course.REFERENCE in " + coursereferencesList;
DataSet course_ds= new DataSet();
DataTable course_dt= new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter = new OleDbDataAdapter
{
SelectCommand = cmd
};
adapter.Fill(course_dt);
course_ds.Tables.Add(course_dt);
The issue I have is that the adapter does not fill the datatable - it only fills in when I specify student references in the query or when the coursereferencesList is significantly smaller. It has been 'stuck' on the adapter.fill part of the code for about 5 minutes now. There are about 40,000 courses in the coursereferencesList list. I would be grateful for any pointers.
UPDATE: I put and try and catch around the adpater.fill and get this error;
The query processor ran out of stack space during query optimization. Please simplify the query.Microsoft SQL Server Native Client 11.0
Many thanks in advance.