Query Oracle system object containing dollar sign ($)...
Posted: Tue 21 Sep 2010 19:09
I am trying to run the following query:
When executed, it throws a System.Data.Entity.SqlException with the following message:
The query syntax is not valid., line 1, column 27
Below is a code snippet that causes the error:
I have tried escaping the query expression, e.g. , but it still throws the same exception.
Is threre any way to query the Oracle system objects that contain a dollar sign?
Thanks,
Welton
Code: Select all
"SELECT version FROM sys.v_$instance"
The query syntax is not valid., line 1, column 27
Below is a code snippet that causes the error:
Code: Select all
DbConnection conn = (System.Data.EntityClient.EntityConnection)context.Connection;
ConnectionState initialState = conn.State;
try
{
if (initialState != ConnectionState.Open)
conn.Open(); // open connection if not already open
try
{
using (DbCommand cmd = conn.CreateCommand())
{
// todo: fix the v_$ error
cmd.CommandText = "SELECT edition FROM sys.v_$instance";
r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
_databaseEdition = r.GetValue(0).ToString();
}
}
}
catch (Exception ex)
{
// eat the error
}
}
finally
{
if (initialState != ConnectionState.Open)
conn.Close(); // only close connection if not initially open
}
Code: Select all
@"SELECT version FROM sys.v_\$instance", "SELECT version FROM sys.v_\$instance", "SELECT version FROM sys.v_\u0024instance"
Is threre any way to query the Oracle system objects that contain a dollar sign?
Thanks,
Welton