Development Tip

ORA-00911 : 잘못된 문자

yourdevel 2020. 12. 9. 21:51
반응형

ORA-00911 : 잘못된 문자


다음과 같이 Oracle (11g) 데이터베이스에 두 개의 테이블을 만듭니다.

    create table "test" ("id" int);
    create table test ("id" int);

그런 다음 내 C # 프로그램에 문제가 있습니다.

    OracleConnection conn = new OracleConnection(-myConnectionString-);
    conn.Open();
    OracleCommand command = new OracleCommand("select * from test;", conn);
    var v = command.ExecuteReader(); 
    OracleCommand command = new OracleCommand("select * from \"test\";", conn);
    var v = command.ExecuteReader(); 

두 command.ExecuteReader ()에 대해 "ORA-00911 : invalid character"오류가 발생했습니다.


제거; (세미콜론) SQL 문자열 끝부터


다른 사람들이 단일 명령에 여러 명령문을 포함하는 방법을 찾고있는 경우, beginend 내에 명령문을 래핑해야합니다 . 세미콜론으로 인한 잘못된 문자 오류를 중지합니다. 예를 들면 :

var command = new OracleCommand(@"
    begin
    select * from test;
    select * from test2;
    end;")

쿼리에서 세미콜론을 사용하는 이유는 ... 유효하지 않은 문자로 간주됩니다 ..... 쿼리에서 세미콜론 (;)을 제거하고 다음과 같이해야합니다.

   OracleConnection conn = new OracleConnection(-myConnectionString-);
   conn.Open();
    OracleCommand command = new OracleCommand("select * from test", conn);
    var v = command.ExecuteReader(); 
    OracleCommand command = new OracleCommand("select * from \"test\"", conn);
    var v = command.ExecuteReader(); 

이 오류에 대한 자세한 내용은 여기를 참조하십시오 .


이것은이 사람의 문제가 아니지만, 이것이 누군가를 도울 수 있기를 바랍니다.

나는 종종 다음과 같이 인라인 주석 안에 숨겨진 작은 따옴표 로이 문제가 있습니다.

select foo 
from bar
where 
/* some helpful comment with a "can't" or somesuch */
baz='qux'

주석에서 타의 추종을 불허하는 작은 따옴표는 모든 종류의 드라마를 유발하며 오라클은 그것을 이해하는 데 도움이되지 않습니다.


, 명령 에서 sqldatasource 매개 변수를 ?바꿉니다 .:Column_namedeleteupdateinsert

참고 URL : https://stackoverflow.com/questions/12262145/ora-00911-invalid-character

반응형