시소당
계좌정보table 은 개인고객 계좌 및 법인고객 계좌로 구성된다. 이를 구현하면 다음의 두가지 방법으로 구현된다.
구현1: create table 계좌정보 (계좌번호 varchar2(10) primary key, ….
고객번호 varchar2(10) not null,
고객종류 varchar2(1) not null
constraint check_type check (고객종류 in (‘1’,’2’));
cursor for select … from ..where
fetch …
if (:고객종류 = ‘1’)
select 성명 into :고객명
from 개인고객정보
where 고객번호 = :고객번호;
 하나의 sql문으로 구현하면 다음과 같다. (개선안)
select a.계좌번호, a.개설일, b.개인고객명, c.법인고객명
from 계좌정보 a, 개인고객 b, 법인고객 c
where a.개설일 like ‘199510%’
and a.고객번호 = b.고객번호(+)
and a.고객번호 = c.고객번호(+)
order by a.개설일;
구현2: create table 계좌정보 (계좌번호 varchar2(10) primary key, ….
개인고객번호 varchar2(10) not null,
법인고객번호 varchar2(10) not null);
cursor for select … from ..where
fetch …
if (:고객종류 != null )
select 성명 into :고객명
from 개인고객정보
where 고객번호 = :고객번호;
 하나의 sql문으로 구현하면 다음과 같다(개선안)
select a.계좌번호, a.개설일, b.개인고객명, c.법인고객명
from 계좌정보 a, 개인고객 b, 법인고객 c
where a.개설일 like ‘199510%’
and a.개인고객번호 = b.고객번호(+)
and a.법인고객번호 = c.고객번호(+)
order by a.개설일;