I need to pass in a query from my server side app to oracle. Using C# and a DbAdapter class that handles the connection and methods to return a DataTable object.
The System.Data.oracleclient.DbSqlParser.Parse2(String SelectStatment) is throwing an exception when trying to parse the following statment which is valid in Oracle:
DbAdapter dbadapter = new DbAdapter();
DataTable ngwbcdpflowTAB = new DataTable();
string selectsql = @"Select sub.proddate, sub.interfacename,sub.cdpid, sub.mmbtu from (select proddate,interfacename,cdpid,mmbtu,btufactor, max(proddate) over (partition by cdpid) max_date from v_ngwbcdpflowinterface where proddate<=" + DbHelper.SqlDate(proddate) + @") sub where sub.proddate = sub.max_date";
dbadapter.FillSchema(ngwbcdpflowTAB, selectsql);
The DBHelper.SQLDate(DateTime foo) method embedded above converts a DateTime c# type to an Oralce To_Date('mm-dd-yyyy', 'mm dd yyyy) expression.
The exception thrown is:
System.InvalidOperationException: Syntax Error: Expecting identifier or quoted identifier.
at System.Data.OracleClient.DbSqlParser.Parse2(String statementText)
at System.Data.OracleClient.DbSqlParser.Parse(String statementText) at System.Data.OracleClient.OracleDataReader.FillSchemaTable(DataTable schemaTable)
at System.Data.OracleClient.OracleDataReader.GetSchemaTable()
at System.Data.ProviderBase.SchemaMapping..ctor(DataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, Boolean keyInfo, SchemaType schemaType, String sourceTableName, Boolean gettingData, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.FillSchemaFromReader(DataSet dataset, DataTable datatable, SchemaType schemaType, String srcTable, IDataReader dataReader)
at System.Data.Common.DataAdapter.FillSchema(DataTable dataTable, SchemaType schemaType, IDataReader dataReader)
at System.Data.Common.DbDataAdapter.FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, String srcTable, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillSchema(DataTable dataTable, SchemaType schemaType, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillSchema(DataTable dataTable, SchemaType schemaType)
Any help appreciated on how to pass in the stated sql onto oracle from .NET