2013-07-30 6 views
0

동적 SQL에서 테이블을 업데이트하고 싶습니다. 동적 SQL - 테이블 변수를 사용하는 테이블 업데이트

declare 
    x varchar2(10) := 'table_n'; 
begin 
    execute immediate 'update :1 set column_n = 12345' using x; 
end; 

나는 ORA-00903를 얻을 : 유효하지 않은 테이블 이름

그러나

declare 
    x varchar2(10) := 'table_n'; 
begin 
    execute immediate 'update ' || x || ' set column_n = 12345'; 
end; 

작품.

첫 번째 해결 방법은 무엇입니까? 더 클릭 여기 들어

1.It generally uses the SQL statements at run time. (for the time which we don't have data at the compilation time). 
2. The bind variable , in your query, `x`, uses it on runtime and execute the dynamic on run time. 
3. the bind variable refered by colon is used after USING clause. 

:

답변

1

당신은 PL/SQL에서 테이블 이름을

0

Usage Notes

"... 바인드 인수를 사용하여 스키마 오브젝트의 이름을 동적 SQL 문에 전달할 수 없습니다 .... "