2014-01-14 9 views

답변

5

실행 된 명령문 수 또는 영향을받은 행의 누적 개수를 쉽게 구할 수 없습니다. 직접 추적하려면 코드를 추가해야합니다. 명령문의 수는 실행할 때마다 하나의 변수에 추가 할 수 있습니다. 영향을받는 행에 대해 사용할 수있는 카운트 SQL%ROWCOUNT implicit cursor attribute :

declare 
    statement_count pls_integer := 0; 
    total_row_count pls_integer := 0; 
begin 
    insert into my_table (id) values (1); 
    statement_count := statement_count + 1; 
    total_row_count := total_row_count + SQL%ROW_COUNT; 
    dbms_output.put_line('Rows affected by statement ' || statement_count 
    || ': ' || SQL%ROWCOUNT); 

    update my_table set id = id + 1; 
    statement_count := statement_count + 1; 
    total_row_count := total_row_count + SQL%ROW_COUNT; 
    dbms_output.put_line('Rows affected by statement ' || statement_count 
    || ': ' || SQL%ROWCOUNT); 

    delete from my_table where id = 2; 
    statement_count := statement_count + 1; 
    total_row_count := total_row_count + SQL%ROW_COUNT; 
    dbms_output.put_line('Rows affected by statement ' || statement_count 
    || ': ' || SQL%ROWCOUNT); 

    dbms_output.put_line('Number of statements: ' || statement_count); 
    dbms_output.put_line('Total rows affected: ' || total_row_count); 
end; 
/

당신이 될 거라면 당신은 최선을 다하고 값에만 관심이 있다면 commit 또는 rollback 후 카운터 (들)을 재설정해야하고, 것입니다 그 중반 블록을하고; 그것은 일반적으로 필요하거나 좋은 생각은 아니지만.

+0

내가 의심하는 바에 따르면 FOO % STATEMNTCOUNT이 (가) 없으며 하나씩 계산해야합니다. –