본문 바로가기

전체 글

(624)
072 - [Oracle PL/SQL] RESULT_CACHE hint result_cache 옵션을 추가하면 동일한 쿼리를 실행할때 캐쉬에서 결과를 가져오므로 처리속도가 아주 빠르다. --1 Cache and parallel are only in oracle enterprise editions --also the DBA make changes in these values # result_cache 옵션 사용은 아래 3개의 파라미터와 밀접한 관계가 있으므로 # dba가 설정을 적절히 정해야만 원하는 결과를 얻을수 있다 --parameter shared_pool_size --parameter result_cache_max_size --parameter result_cache_mode create or replace function get_sum_sal_dept ( dept_i..
071 - [Oracle PL/SQL] PARALLEL_ENABLE hint 아래처럼 처리하면 쿼리를 병렬로 처리가능하다. 대신에 함수선언시 위에 처럼 선언해야 한다. Cache and parallel are only in oracle enterprise editions https://docs.oracle.com/database/121/DBLIC/editions.htm#DBLIC116 Licensing Information ANTLR Antlr ANTLR 3 License [The BSD License] Copyright (c) 2003-2007, Terence Parr All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted pr..
070 - [Oracle PL/SQL] NOCOPY - 성능차이. 값 전달과 레퍼런스 전달의 속도 차이를 테스트해보자. create or replace package nocopy_test is type number_t is table of varchar2(20) index by binary_integer; procedure pass_by_vale(nums in out number_t); procedure pass_by_refernce(nums in out nocopy number_t); procedure init; end; / ------------ create or replace package body nocopy_test is l_numbers number_t; c_array_size number:=1000000; c_it number:=20; procedure p..
069 - [Oracle PL/SQL] NOCOPY 예외상황 # nocopy will have no effects # case 1 create or replace procedure pass_by_value3 ( P_id IN out nocopy number) is begin P_id:=P_id*10; if P_id>100 then raise VALUE_ERROR; end if; end; / # 값에 사이즈를 지정하면 nocopy 옵션이 동작하지 않는다 declare --if the actual has size(FOR NUMBER ONLY ),nocopy not working v number(10):=20; begin pass_by_value3(V); dbms_output.put_line('NO ISSUE '||v); EXCEPTION WHEN VALUE_ERROR..
068 - [Oracle PL/SQL] NOCOPY We use NOCOPY in complexe data types (LOBs, XMLTYPEs, collections etc.) 여기서 레퍼런스에 의한 전달과 값에 의한 전달의 차이를 알아보자 IN parameter always passed by reference, IN 파라미터는 항상 레퍼런스에 의한 전달이다 OUT/IN OUT parameters can be passed 1-Pass By Value ( default), 파라미터의 사이즈가 작다면 문제가 없지만 크다면 복사하는 과정에서 많은 부하가 발생한다. 값의 전달은, 오류가 발생할때, 프로시져에 전달한 값이 무엇인지 알고 롤백을 할때도 값을 유지한다. 2-Pass By Reference using no copy, 복사 과정이 일어나지 않아서 실행..
067 - [Oracle PL/SQL] AUTONOMOUS TRANSACTION 블록간 구분이 없어서 subprogram 에서 실행한 commit 이 main procedure 에 영향을 미치는 샘플 코드 #case one without using PRAGMA AUTONOMOUS_TRANSACTION drop table t; # hr 사용자 세션에서 실행 CREATE TABLE t (test_value VARCHAR2(25)); / CREATE OR REPLACE PROCEDURE child_block IS BEGIN INSERT INTO t(test_value) VALUES ('Child block insert'); COMMIT; END child_block; / CREATE OR REPLACE PROCEDURE parent_block IS BEGIN INSERT INTO t(te..
066 - [Oracle PL/SQL] Design - Definer's right, Invoker's rights Definer's rights 무슨 의미인지 샘플 코드를 통해서 확인 # 테스트를 위한 준비과정 # hr 사용자로 디비 접속해서 테이블 생성. create table hr_table ( id number, name varchar2(100) ); /* Table HR_TABLE created. */ create or replace procedure add_hr_table ( p_id number, p_name varchar2 ) is begin insert into hr_table values (p_id,p_name); end; /* Procedure ADD_HR_TABLE compiled */ # 여기부터는 sys 사용자로 접속하여 실행 --now conn as sys as sysdba and creat..
065 - [Oracle PL/SQL] Design - Standardizing 에러처리를 고급스럽게 처리하는 방법, 샘플코드, 사용자 정의 오류와 오라클 표준 에러를 동시에 처리하는 방법 delete from DEPARTMENTS /* Error report - ORA-02292: integrity constraint (HR.EMP_DEPT_FK) violated - child record found */ declare e_fk_err exception; pragma EXCEPTION_INIT (e_fk_err, -02292); begin delete from DEPARTMENTS; exception when e_fk_err then RAISE_APPLICATION_ERROR (-20001, 'error'); end; /* Error report - ORA-20001: error ..