c# – Oracle ADO query fails

Question:

I am trying to execute a request to the Oracle server. There is definitely a connection to the server.

var connectionString = @"select distinct a.tablespace_name, SUM(a.bytes)/1024/1024, SUM(decode(b.maxextend, null, A.BYTES/1024/1024, b.maxextend*8192/1024/1024)), (SUM(a.bytes)/1024/1024 - round(c.Free/1024/1024)), (SUM(decode(b.maxextend, null, A.BYTES/1024/1024, b.maxextend*8192/1024/1024)) - (SUM(a.bytes)/1024/1024 - round(c.Free/1024/1024))), round(100*(SUM(a.bytes)/1024/1024 - round(c.Free/1024/1024))/(SUM(decode(b.maxextend, null, A.BYTES/1024/1024, b.maxextend*8192/1024/1024)))) from dba_data_files a, sys.filext$ b, (SELECT d.tablespace_name , sum(nvl(c.bytes,0)) Free FROM dba_tablespaces d,DBA_FREE_SPACE c where d.tablespace_name = c.tablespace_name(+) group by d.tablespace_name) c where a.file_id = b.file#(+) and a.tablespace_name = c.tablespace_name group by a.tablespace_name, c.Free/1024 order by round(100*(SUM(a.bytes)/1024/1024 - round(c.Free/1024/1024))/(SUM(decode(b.maxextend, null, A.BYTES/1024/1024, b.maxextend*8192/1024/1024)))) desc; ";

OracleCommand cursCmd = new OracleCommand(connectionString, connection);

OracleDataReader reader = cursCmd.ExecuteReader();

I get an exception – {"ORA-00911: invalid character"} – on line

OracleDataReader reader = cursCmd.ExecuteReader();

Moreover, if you execute the request on the server itself (just copy the contents of the connectionString), then it passes without errors

What am I doing wrong?

Answer:

What am I doing wrong?

var connectionString = @"select .... desc; ";

Extra semicolon ;

Nevertheless, I recommend that instead of reusing the connectionString variable for the request text, use a new variable so that the name does not mislead people who will read your code.

Scroll to Top