PC Review


Reply
Thread Tools Rate Thread

ADO.NET / Oracle problem

 
 
Bill Zack
Guest
Posts: n/a
 
      23rd Mar 2004
We have a table in Oracle described as the following:

SQL> desc cubetest
Name Null? Type
----------------------------------------- --------
----------------------------
COL1 NUMBER
COLB NUMBER
COLC VARCHAR2(3)

We populate it with some data and try to execute a select statement.

The following select statement executes fine under sqlplus, but when
we try to run it using the .NET OracleClient we get this:
Encountered an exception while preparing the SQL statement.
System.Data.OracleClient.OracleException: ORA-03001: unimplemented
feature

at System.Data.OracleClient.OracleConnection.CheckError(OciHandle
errorHandle, Int32 rc)
at System.Data.OracleClient.OracleCommand.Prepare()
at Script.Main(String[] args)

SQL:
select sum(col1) "COL1", count(distinct Colb),'abc',colc "C" from
cubetest where col1 =1 group by cube(COL1,'abc',colc)

If we change count(distinct Colb) to count(Colb) or we change the
group by expression to group by COL1,'abc',colc then this query works.
Has anyone encountered a problem executing select statements with this
combination of expressions?

Below is the C# code used to execute test this:
using System;
using System.Data;
using System.Data.OracleClient;
using System.Windows.Forms;
using System.IO;
class Script
{
public static void Main(string[] args)
{

if(args.Length < 2){
Console.WriteLine("usage:
sqlrunner <connect string> <sql statement> [[<param name> <param
value>] ...]");
return;
}
string connectString = args[0];
string sql = args[1];
if(args[1][0] == '@'){
if(args[1].Length == 1){
Console.WriteLine("No
file specified.");
return;
}
string filename =
args[1].Substring(1);
StreamReader reader =
File.OpenText(filename);
try{
sql =
reader.ReadToEnd();
}finally{
reader.Close();
}

}

OracleConnection dbConn = new
OracleConnection(connectString);
OracleCommand cmd = new
OracleCommand(sql,dbConn);
try{
try{
dbConn.Open();
}catch{
Console.WriteLine("Failed to open
connection");
return;
}

bool parseOk = true;
bool executeOk = true;

try {
cmd.Prepare();
} catch (Exception ex){
Console.WriteLine("Encountered an
exception while preparing the SQL statement.\n"+ex+"\n"+"STACK
TRACE-----------------------\n"+ex.StackTrace);
parseOk = false;
}
OracleDataAdapter da = new
OracleDataAdapter(cmd);
DataSet ds = new DataSet("Results");
if(parseOk){
try{
da.Fill(ds);
}catch(Exception ex){

Console.WriteLine("Encountered an exception while executing the SQL
statement.\n"+ex.Message+"\n"+"STACK
TRACE-----------------------\n"+ex.StackTrace);
executeOk = false;
}finally{
dbConn.Close();
}

if(!executeOk) return;

try{

ds.WriteXml("results.xml",XmlWriteMode.IgnoreSchema);

Console.WriteLine(ds.GetXml());

Console.WriteLine("________________________________________________");

Console.WriteLine("Results have been written to results.xml");
}catch(Exception ex){

Console.WriteLine("Encountered an exception while retrieving
data.\n"+ex.Message+"\n"+"STACK
TRACE-----------------------\n"+ex.StackTrace);
}
}
}finally{
dbConn.Close();
}
}
}

The command line used would look something like this:
sqlrunner "User Id=test;Password=pss;Data Source=dev9" @test2.sql
where test2.sql contains the select statement you want to execute.

We are using the Microsoft oracle provider.

Thanks
Bill Zack
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      24th Mar 2004
Hi Bill,

I've seen similar weirdness with Oracle.
Which oracle client are you using?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Bill Zack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> We have a table in Oracle described as the following:
>
> SQL> desc cubetest
> Name Null? Type
> ----------------------------------------- --------
> ----------------------------
> COL1 NUMBER
> COLB NUMBER
> COLC VARCHAR2(3)
>
> We populate it with some data and try to execute a select statement.
>
> The following select statement executes fine under sqlplus, but when
> we try to run it using the .NET OracleClient we get this:
> Encountered an exception while preparing the SQL statement.
> System.Data.OracleClient.OracleException: ORA-03001: unimplemented
> feature
>
> at System.Data.OracleClient.OracleConnection.CheckError(OciHandle
> errorHandle, Int32 rc)
> at System.Data.OracleClient.OracleCommand.Prepare()
> at Script.Main(String[] args)
>
> SQL:
> select sum(col1) "COL1", count(distinct Colb),'abc',colc "C" from
> cubetest where col1 =1 group by cube(COL1,'abc',colc)
>
> If we change count(distinct Colb) to count(Colb) or we change the
> group by expression to group by COL1,'abc',colc then this query works.
> Has anyone encountered a problem executing select statements with this
> combination of expressions?
>
> Below is the C# code used to execute test this:
> using System;
> using System.Data;
> using System.Data.OracleClient;
> using System.Windows.Forms;
> using System.IO;
> class Script
> {
> public static void Main(string[] args)
> {
>
> if(args.Length < 2){
> Console.WriteLine("usage:
> sqlrunner <connect string> <sql statement> [[<param name> <param
> value>] ...]");
> return;
> }
> string connectString = args[0];
> string sql = args[1];
> if(args[1][0] == '@'){
> if(args[1].Length == 1){
> Console.WriteLine("No
> file specified.");
> return;
> }
> string filename =
> args[1].Substring(1);
> StreamReader reader =
> File.OpenText(filename);
> try{
> sql =
> reader.ReadToEnd();
> }finally{
> reader.Close();
> }
>
> }
>
> OracleConnection dbConn = new
> OracleConnection(connectString);
> OracleCommand cmd = new
> OracleCommand(sql,dbConn);
> try{
> try{
> dbConn.Open();
> }catch{
> Console.WriteLine("Failed to open
> connection");
> return;
> }
>
> bool parseOk = true;
> bool executeOk = true;
>
> try {
> cmd.Prepare();
> } catch (Exception ex){
> Console.WriteLine("Encountered an
> exception while preparing the SQL statement.\n"+ex+"\n"+"STACK
> TRACE-----------------------\n"+ex.StackTrace);
> parseOk = false;
> }
> OracleDataAdapter da = new
> OracleDataAdapter(cmd);
> DataSet ds = new DataSet("Results");
> if(parseOk){
> try{
> da.Fill(ds);
> }catch(Exception ex){
>
> Console.WriteLine("Encountered an exception while executing the SQL
> statement.\n"+ex.Message+"\n"+"STACK
> TRACE-----------------------\n"+ex.StackTrace);
> executeOk = false;
> }finally{
> dbConn.Close();
> }
>
> if(!executeOk) return;
>
> try{
>
> ds.WriteXml("results.xml",XmlWriteMode.IgnoreSchema);
>
> Console.WriteLine(ds.GetXml());
>
> Console.WriteLine("________________________________________________");
>
> Console.WriteLine("Results have been written to results.xml");
> }catch(Exception ex){
>
> Console.WriteLine("Encountered an exception while retrieving
> data.\n"+ex.Message+"\n"+"STACK
> TRACE-----------------------\n"+ex.StackTrace);
> }
> }
> }finally{
> dbConn.Close();
> }
> }
> }
>
> The command line used would look something like this:
> sqlrunner "User Id=test;Password=pss;Data Source=dev9" @test2.sql
> where test2.sql contains the select statement you want to execute.
>
> We are using the Microsoft oracle provider.
>
> Thanks
> Bill Zack



 
Reply With Quote
 
Bill Zack
Guest
Posts: n/a
 
      24th Mar 2004
We have tried it with 8.1.7 and 9.2 with the same results.
Bill Zack


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message news:<(E-Mail Removed)>...
> Hi Bill,
>
> I've seen similar weirdness with Oracle.
> Which oracle client are you using?
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & software development
> miha at rthand com
> www.rthand.com
>
> "Bill Zack" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > We have a table in Oracle described as the following:
> >
> > SQL> desc cubetest
> > Name Null? Type
> > ----------------------------------------- --------
> > ----------------------------
> > COL1 NUMBER
> > COLB NUMBER
> > COLC VARCHAR2(3)
> >
> > We populate it with some data and try to execute a select statement.
> >
> > The following select statement executes fine under sqlplus, but when
> > we try to run it using the .NET OracleClient we get this:
> > Encountered an exception while preparing the SQL statement.
> > System.Data.OracleClient.OracleException: ORA-03001: unimplemented
> > feature
> >
> > at System.Data.OracleClient.OracleConnection.CheckError(OciHandle
> > errorHandle, Int32 rc)
> > at System.Data.OracleClient.OracleCommand.Prepare()
> > at Script.Main(String[] args)
> >
> > SQL:
> > select sum(col1) "COL1", count(distinct Colb),'abc',colc "C" from
> > cubetest where col1 =1 group by cube(COL1,'abc',colc)
> >
> > If we change count(distinct Colb) to count(Colb) or we change the
> > group by expression to group by COL1,'abc',colc then this query works.
> > Has anyone encountered a problem executing select statements with this
> > combination of expressions?
> >
> > Below is the C# code used to execute test this:
> > using System;
> > using System.Data;
> > using System.Data.OracleClient;
> > using System.Windows.Forms;
> > using System.IO;
> > class Script
> > {
> > public static void Main(string[] args)
> > {
> >
> > if(args.Length < 2){
> > Console.WriteLine("usage:
> > sqlrunner <connect string> <sql statement> [[<param name> <param
> > value>] ...]");
> > return;
> > }
> > string connectString = args[0];
> > string sql = args[1];
> > if(args[1][0] == '@'){
> > if(args[1].Length == 1){
> > Console.WriteLine("No
> > file specified.");
> > return;
> > }
> > string filename =
> > args[1].Substring(1);
> > StreamReader reader =
> > File.OpenText(filename);
> > try{
> > sql =
> > reader.ReadToEnd();
> > }finally{
> > reader.Close();
> > }
> >
> > }
> >
> > OracleConnection dbConn = new
> > OracleConnection(connectString);
> > OracleCommand cmd = new
> > OracleCommand(sql,dbConn);
> > try{
> > try{
> > dbConn.Open();
> > }catch{
> > Console.WriteLine("Failed to open
> > connection");
> > return;
> > }
> >
> > bool parseOk = true;
> > bool executeOk = true;
> >
> > try {
> > cmd.Prepare();
> > } catch (Exception ex){
> > Console.WriteLine("Encountered an
> > exception while preparing the SQL statement.\n"+ex+"\n"+"STACK
> > TRACE-----------------------\n"+ex.StackTrace);
> > parseOk = false;
> > }
> > OracleDataAdapter da = new
> > OracleDataAdapter(cmd);
> > DataSet ds = new DataSet("Results");
> > if(parseOk){
> > try{
> > da.Fill(ds);
> > }catch(Exception ex){
> >
> > Console.WriteLine("Encountered an exception while executing the SQL
> > statement.\n"+ex.Message+"\n"+"STACK
> > TRACE-----------------------\n"+ex.StackTrace);
> > executeOk = false;
> > }finally{
> > dbConn.Close();
> > }
> >
> > if(!executeOk) return;
> >
> > try{
> >
> > ds.WriteXml("results.xml",XmlWriteMode.IgnoreSchema);
> >
> > Console.WriteLine(ds.GetXml());
> >
> > Console.WriteLine("________________________________________________");
> >
> > Console.WriteLine("Results have been written to results.xml");
> > }catch(Exception ex){
> >
> > Console.WriteLine("Encountered an exception while retrieving
> > data.\n"+ex.Message+"\n"+"STACK
> > TRACE-----------------------\n"+ex.StackTrace);
> > }
> > }
> > }finally{
> > dbConn.Close();
> > }
> > }
> > }
> >
> > The command line used would look something like this:
> > sqlrunner "User Id=test;Password=pss;Data Source=dev9" @test2.sql
> > where test2.sql contains the select statement you want to execute.
> >
> > We are using the Microsoft oracle provider.
> >
> > Thanks
> > Bill Zack

 
Reply With Quote
 
Bill Zack
Guest
Posts: n/a
 
      24th Mar 2004
We have tried it with 8.1.7 and 9.2 with the same results.

Thanks
Bill Zack


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message news:<(E-Mail Removed)>...
> Hi Bill,
>
> I've seen similar weirdness with Oracle.
> Which oracle client are you using?
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & software development
> miha at rthand com
> www.rthand.com
>
> "Bill Zack" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > We have a table in Oracle described as the following:
> >
> > SQL> desc cubetest
> > Name Null? Type
> > ----------------------------------------- --------
> > ----------------------------
> > COL1 NUMBER
> > COLB NUMBER
> > COLC VARCHAR2(3)
> >
> > We populate it with some data and try to execute a select statement.
> >
> > The following select statement executes fine under sqlplus, but when
> > we try to run it using the .NET OracleClient we get this:
> > Encountered an exception while preparing the SQL statement.
> > System.Data.OracleClient.OracleException: ORA-03001: unimplemented
> > feature
> >
> > at System.Data.OracleClient.OracleConnection.CheckError(OciHandle
> > errorHandle, Int32 rc)
> > at System.Data.OracleClient.OracleCommand.Prepare()
> > at Script.Main(String[] args)
> >
> > SQL:
> > select sum(col1) "COL1", count(distinct Colb),'abc',colc "C" from
> > cubetest where col1 =1 group by cube(COL1,'abc',colc)
> >
> > If we change count(distinct Colb) to count(Colb) or we change the
> > group by expression to group by COL1,'abc',colc then this query works.
> > Has anyone encountered a problem executing select statements with this
> > combination of expressions?
> >
> > Below is the C# code used to execute test this:
> > using System;
> > using System.Data;
> > using System.Data.OracleClient;
> > using System.Windows.Forms;
> > using System.IO;
> > class Script
> > {
> > public static void Main(string[] args)
> > {
> >
> > if(args.Length < 2){
> > Console.WriteLine("usage:
> > sqlrunner <connect string> <sql statement> [[<param name> <param
> > value>] ...]");
> > return;
> > }
> > string connectString = args[0];
> > string sql = args[1];
> > if(args[1][0] == '@'){
> > if(args[1].Length == 1){
> > Console.WriteLine("No
> > file specified.");
> > return;
> > }
> > string filename =
> > args[1].Substring(1);
> > StreamReader reader =
> > File.OpenText(filename);
> > try{
> > sql =
> > reader.ReadToEnd();
> > }finally{
> > reader.Close();
> > }
> >
> > }
> >
> > OracleConnection dbConn = new
> > OracleConnection(connectString);
> > OracleCommand cmd = new
> > OracleCommand(sql,dbConn);
> > try{
> > try{
> > dbConn.Open();
> > }catch{
> > Console.WriteLine("Failed to open
> > connection");
> > return;
> > }
> >
> > bool parseOk = true;
> > bool executeOk = true;
> >
> > try {
> > cmd.Prepare();
> > } catch (Exception ex){
> > Console.WriteLine("Encountered an
> > exception while preparing the SQL statement.\n"+ex+"\n"+"STACK
> > TRACE-----------------------\n"+ex.StackTrace);
> > parseOk = false;
> > }
> > OracleDataAdapter da = new
> > OracleDataAdapter(cmd);
> > DataSet ds = new DataSet("Results");
> > if(parseOk){
> > try{
> > da.Fill(ds);
> > }catch(Exception ex){
> >
> > Console.WriteLine("Encountered an exception while executing the SQL
> > statement.\n"+ex.Message+"\n"+"STACK
> > TRACE-----------------------\n"+ex.StackTrace);
> > executeOk = false;
> > }finally{
> > dbConn.Close();
> > }
> >
> > if(!executeOk) return;
> >
> > try{
> >
> > ds.WriteXml("results.xml",XmlWriteMode.IgnoreSchema);
> >
> > Console.WriteLine(ds.GetXml());
> >
> > Console.WriteLine("________________________________________________");
> >
> > Console.WriteLine("Results have been written to results.xml");
> > }catch(Exception ex){
> >
> > Console.WriteLine("Encountered an exception while retrieving
> > data.\n"+ex.Message+"\n"+"STACK
> > TRACE-----------------------\n"+ex.StackTrace);
> > }
> > }
> > }finally{
> > dbConn.Close();
> > }
> > }
> > }
> >
> > The command line used would look something like this:
> > sqlrunner "User Id=test;Password=pss;Data Source=dev9" @test2.sql
> > where test2.sql contains the select statement you want to execute.
> >
> > We are using the Microsoft oracle provider.
> >
> > Thanks
> > Bill Zack

 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      25th Mar 2004
Hi Bill,

I have tried the following code you have provided on Oracle's sqlplus.

select sum(col1) "COL1", count(distinct Colb),'abc',colc "C" from
cubetest where col1 =1 group by cube(COL1,'abc',colc)

However, an error ORA-30480: DISTINCT option not allowed with GROUP BY CUBE
or ROLLUP was thrown. It seem that the Oracle server dosen't allow DISTINCT
and GROUP BY CUBE in the same statement.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
Bill Zack
Guest
Posts: n/a
 
      25th Mar 2004
Thanks for the response Kevin.

Which Oracle client did you use? We had the problem with 8.1.7 and 9.2.

We sent the sample program to Developer Support and they were able to
re-create the problem. They said that they are working with Oracle to
resolve it now.

Bill Zack


"Kevin Yu [MSFT]" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Bill,
>
> I have tried the following code you have provided on Oracle's sqlplus.
>
> select sum(col1) "COL1", count(distinct Colb),'abc',colc "C" from
> cubetest where col1 =1 group by cube(COL1,'abc',colc)
>
> However, an error ORA-30480: DISTINCT option not allowed with GROUP BY

CUBE
> or ROLLUP was thrown. It seem that the Oracle server dosen't allow

DISTINCT
> and GROUP BY CUBE in the same statement.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      26th Mar 2004
Hi Bill,

I have tried it on Oracle client 8.1.7. It gives the error which says
ORA-30480: DISTINCT option not allowed with GROUP BY CUBE or ROLLUP. Have
you created a case with Microsoft PSS? Please feel free to let me know, if
I can provide help.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
Bill Zack
Guest
Posts: n/a
 
      26th Mar 2004
Yes we opened a case. They were able to re-create it and they are
working with Oracle to resolve it. I will post the solution here when
they come up with one.

Thanks
Bill



v-(E-Mail Removed) (Kevin Yu [MSFT]) wrote in message news:<(E-Mail Removed)>...
> Hi Bill,
>
> I have tried it on Oracle client 8.1.7. It gives the error which says
> ORA-30480: DISTINCT option not allowed with GROUP BY CUBE or ROLLUP. Have
> you created a case with Microsoft PSS? Please feel free to let me know, if
> I can provide help.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."

 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      29th Mar 2004
Hi Bill,

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with oracle database connection using Oracle Instant Clien PIYUSH Microsoft Outlook Program Addins 0 5th Jun 2008 10:11 AM
Sequence.nextval numeric type in Oracle 10g differs from Oracle 8i when using MS OleDb provider alasdair.johnson@gmail.com Microsoft ASP .NET 0 27th Apr 2007 05:57 PM
Pass an array to an Oracle stored procedure using Microsoft's client for Oracle michelle.m.talt@gmail.com Microsoft ADO .NET 0 16th Jun 2006 04:34 PM
Oracle Connection Problem with Microsoft .NET Provider for ORACLE =?Utf-8?B?QW5kcmV3?= Microsoft ADO .NET 7 11th May 2004 03:30 PM
How to connect oracle 8i when oracle 8i and oracle 9i installed in one system Prasad Microsoft ADO .NET 0 1st Dec 2003 10:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 AM.