C#에서 단일 Oracle 명령어로 여러 쿼리 실행
저는 비주얼 스튜디오 2013과 오라클 데이터베이스를 사용하고 있습니다.여러 개의 생성 테이블 쿼리를 한 번에 단일 오라클 명령으로 실행하고 싶은데 가능합니까?저는 팔로우를 시도하고 있지만 일을 하지 않습니다.
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "create table test(name varchar2(50) not null)"+"create table test2(name varchar2(50) not null)";
//+ "create table test3(name varchar2(50) not null)"+"create table test3(name varchar2(50) not null)";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
cmd에서 오류가 발생했습니다.비쿼리 실행();
두 개 이상의 명령을 실행하려면 해당 명령을 입력합니다.begin ... end;
블록. 그리고 DDL문에 대해서도 (예를 들어).create table
)와 함께 운영합니다.execute immediate
. 이 코드는 내게 효과가 있었습니다.
OracleConnection con = new OracleConnection(connectionString);
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText =
"begin " +
" execute immediate 'create table test1(name varchar2(50) not null)';" +
" execute immediate 'create table test2(name varchar2(50) not null)';" +
"end;";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
con.Close();
자세한 정보:Oracle.ODP를 사용하여 SQL 스크립트 실행
해보셨습니까?
cmd.CommandText = "create table test(name varchar2(50) not null);"+"create table test2(name varchar2(50) not null);";
언급URL : https://stackoverflow.com/questions/31917301/execute-multiple-queries-in-single-oracle-command-in-c-sharp
'programing' 카테고리의 다른 글
작동 오류: (2002, "socket '/var/run/mysqld/mysqld를 통해 로컬 MySQL 서버에 연결할 수 없습니다.양말'(2)) (0) | 2023.11.05 |
---|---|
왜 '익명'이스프링 시큐리티에서 인증된 사용자? (0) | 2023.11.05 |
드롭다운 메뉴를 만들기 위해 Ajax와 JSON을 사용하는 방법은? (0) | 2023.11.05 |
Powershell Console에서 여러 줄 문자열을 할당하는 방법 (0) | 2023.11.05 |
C에서 printf() 함수의 반환 값 (0) | 2023.10.31 |