Forum Stats

  • 3,733,252 Users
  • 2,246,738 Discussions
  • 7,856,634 Comments

Discussions

Error ORA-00903

610527
610527 Member Posts: 2
edited November 2007 in ODP.NET
Hi,

i receive the Error ORA-00903 when i try to execute a SELECT statement in a C# program, which is working in SQL Plus.
Here the program:
OracleCommand ocom;
OracleConnectionStringBuilder ocb;
OracleConnection oc;

ocb = new OracleConnectionStringBuilder();
ocb.DataSource = "XXX";
ocb.Password = "xxx";
ocb.UserID = "xxx";
oc = new OracleConnection(ocb.ConnectionString);
oc.Open();
ocom = new OracleCommand("select ordernr from order", oc);
try
{
OracleDataReader or = ocom.ExecuteReader();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

I am using VS2005 on WIndows Vista 64 Enterprise and the ORACLE DATA PROVIDER FOR .NET 11.1.0.6.10 BETA. It's the only one which works with Vista 64, as i know.

best regards
Erwin

Comments

  • 24208
    24208 Member Posts: 1,295
    Hi Erwin,

    Is the "order" object just a "regular" table? Is there anything "special" about it?

    Do you know the setting for the cursor_sharing parameter on the database? You can connect via SQL*Plus as a dba user and issue "show parameter cursor_sharing" to determine if needed.

    Thanks,

    Mark
  • gdarling - oracle
    gdarling - oracle Member Posts: 2,034
    edited November 2007
    Hi,

    You probably want to rethink the use of an Oracle Reserved Word (and a sql keyword) for a table name..

    1* select count(*) from v$reserved_words where keyword ='ORDER'
    SQL> /

    COUNT(*)
    ----------
    1



    You cant even create a table with that name unless you enclose the name in double quotes..

    SQL> create table order (ordern number);
    create table order (ordern number)
    *
    ERROR at line 1:
    ORA-00903: invalid table name


    SQL> create table "order" (ordern number);

    Table created.




    I'm not sure about your statement that " it works fine in sqlplus", as it certainly doesnt for me, unless I enclose it in double quotes..

    SQL> select * from order;
    select * from order
    *
    ERROR at line 1:
    ORA-00903: invalid table name


    SQL> select * from "order";

    no rows selected


    I didnt actually try it, but I suspect you just need to use double quotes in your query from ODP as well.



    Hope it helps,
    Greg
  • 24208
    24208 Member Posts: 1,295
    D'oh! Thanks Greg...

    - Mark
  • 610527
    610527 Member Posts: 2
    Hi,

    i tried now this "select * from \"QZWICK01\" " (the real table was not "order" but "qzwick01", i took it only as example) and now it is working. I checked also the
    parameter cursor_sharing, here the result:


    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing string EXACT

    many thanks for you help
    - Erwin
This discussion has been closed.