Hi
I'm trying to run a queries on a schema, and I keep getting ORA-00911:
invalid character error. If I copy/paste it in SQL/Plus it runs fine.

This is what I'm doing in code:

//Set session here to ZGK037_MDB

string sqlSession = string.Format("ALTER SESSION SET
CURRENT_SCHEMA={0}", oDB.DatabaseName);

//Note I don't close the Connection Object in this call. It just gets
an OracleCommand Object
cmdOracle = MiscDataUtils.GetCommandObj(sqlSession, oDB.Connection);

//Execute the sqlSession query
cmdOracle.ExecuteNonQuery();

//This is what it shows in my logfile...so it looks like the above
worked with no exceptions
[Logging-DEBUG]-9/29/2006 10:22:45 AM
[GetCommandObj]
ALTER SESSION SET CURRENT_SCHEMA=ZGK037_MDB

Next I try to run a query on this command obj

cmdOracle.CommandText = sql; //Set to my new SQL string
rdr = MiscDataUtils.GetDataReaderFromCommandObj(cmdOracle);

This is what the log file says:


[Logging-DEBUG]-9/29/2006 10:22:45 AM
[GetDataReaderFromCommandObj]
Select RoFm.SymCount as Occ, csd.oid as SymbolOID, csd.m_progID as
ProgID, csd.m_version as ProgVersion From CORESymbolDefinition csd,
(Select Count(*) as SymCount, fm.m_defname as RoFmID FROM
CORERelationOrigin RO JOIN COREFlavorMgr FM ON RO.oidTarget = FM.oid
JOIN CORESymbol S ON RO.oid = S.oid Group By fm.m_defname ) RoFm
Where csd.m_progID=RoFm.RoFmID Order by csd.m_progID;
[Exception]
ORA-00911: invalid character

Any help is really appreciated.

Sunit

Re: Getting Oracle Error by sjoshi

sjoshi
Fri Sep 29 14:35:44 CDT 2006

Found it the problem was trailing semi-colon

Sunit

sjoshi wrote:
> Hi
> I'm trying to run a queries on a schema, and I keep getting ORA-00911:
> invalid character error. If I copy/paste it in SQL/Plus it runs fine.
>
> This is what I'm doing in code:
>
> //Set session here to ZGK037_MDB
>
> string sqlSession = string.Format("ALTER SESSION SET
> CURRENT_SCHEMA={0}", oDB.DatabaseName);
>
> //Note I don't close the Connection Object in this call. It just gets
> an OracleCommand Object
> cmdOracle = MiscDataUtils.GetCommandObj(sqlSession, oDB.Connection);
>
> //Execute the sqlSession query
> cmdOracle.ExecuteNonQuery();
>
> //This is what it shows in my logfile...so it looks like the above
> worked with no exceptions
> [Logging-DEBUG]-9/29/2006 10:22:45 AM
> [GetCommandObj]
> ALTER SESSION SET CURRENT_SCHEMA=ZGK037_MDB
>
> Next I try to run a query on this command obj
>
> cmdOracle.CommandText = sql; //Set to my new SQL string
> rdr = MiscDataUtils.GetDataReaderFromCommandObj(cmdOracle);
>
> This is what the log file says:
>
>
> [Logging-DEBUG]-9/29/2006 10:22:45 AM
> [GetDataReaderFromCommandObj]
> Select RoFm.SymCount as Occ, csd.oid as SymbolOID, csd.m_progID as
> ProgID, csd.m_version as ProgVersion From CORESymbolDefinition csd,
> (Select Count(*) as SymCount, fm.m_defname as RoFmID FROM
> CORERelationOrigin RO JOIN COREFlavorMgr FM ON RO.oidTarget = FM.oid
> JOIN CORESymbol S ON RO.oid = S.oid Group By fm.m_defname ) RoFm
> Where csd.m_progID=RoFm.RoFmID Order by csd.m_progID;
> [Exception]
> ORA-00911: invalid character
>
> Any help is really appreciated.
>
> Sunit