테이블을 커서로 읽어 루프를 돌리면서 insert / update하는 프로시져인데
인포믹스를 처음 사용하여 프로시져 문법을 잘 모르겠어요
계속 문법 에러가 나는데 어디가 문제인지 봐주세요
[문제의 프로시져]
-- KBP 마스타
Create Procedure KN_MAster (
p_Date integer
)
returning integer;
begin Declare Section;
char standcode[12];
char standkorname[40];
int balhaengilja;
int machulilja;
int mangiilja;
float couponiyul;
float balhaengiyul;
float halinyul;
char ijagyesangb[2];
int ijagyesangigan;
char ijahusungb[1];
char gwasegb[1];
char sinyongcode[4];
char sinyongrank[4];
char byunrucode[7];
char byunruname[40];
char companycode[5];
char balhangcode[5];
char balhaenggigwan[40];
char bojungcode[5];
char bojungrank[4];
char bojungname[40];
char saupjacode[10];
char beobincode[13];
char balhaengrank[4];
char gongsagb[1];
char jasanmovegb[1];
end Declare Section;
declare Acur Cursor for
select standcode, standkorname, balhaengilja, machulilja, mangiilja, couponiyul,
balhaengiyul, halinyul, ijagyesangb, ijagyesangigan, ijahusungb, gwasegb,
sinyongcode, sinyongrank, byunrucode, byunruname, companycode, balhangcode,
balhaenggigwan, bojungcode, bojungrank, bojungname, saupjacode, beobincode,
balhaengrank, gongsagb, jasanmovegb
from bdKBPsise
where Gijunilja = p_Date;
open Acur;
Fetch Acur :standcode, :standkorname, :balhaengilja, :machulilja, :mangiilja, :couponiyul,
:balhaengiyul, :halinyul, :ijagyesangb, :ijagyesangigan, :ijahusungb, :gwasegb,
:sinyongcode, :sinyongrank, :byunrucode, :byunruname, :companycode, :balhangcode,
:balhaenggigwan, :bojungcode, :bojungrank, :bojungname, :saupjacode, :beobincode,
:balhaengrank, :gongsagb, :jasanmovegb;
while (Sqlcode == 0)
[
if Exists(select * from bdknmaster where standcode = :stand)
{
--KBP Insert
insert into bdKNMaster
select standcode, standkorname, balhaengilja, machulilja, mangiilja, couponiyul,
balhaengiyul, halinyul, ijagyesangb, ijagyesangigan, ijahusungb, gwasegb,
sinyongcode, sinyongrank, byunrucode, byunruname, companycode, balhangcode,
balhaenggigwan, bojungcode, bojungrank, bojungname, saupjacode, beobincode,
balhaengrank, gongsagb, jasanmovegb
from bdKBPsise
where Gijunilja = p_Date
and standcode = :standcode;
}
else
{
-- KBP Update
update bdKNMaster set
standkorname = :standkorname,
balhaengilja = :balhaengilja, machulilja = :machulilja,
mangiilja = :mangiilja, couponiyul = :couponiyul,
balhaengiyul = :balhaengiyul, halinyul = :halinyul,
ijagyesangb = :ijagyesangb, ijagyesangigan = :ijagyesangigan,
ijahusungb = :ijahusungb, gwasegb = :gwasegb,
sinyongcode = :sinyongcode, sinyongrank = :sinyongrank,
byunrucode = :byunrucode, byunruname = :byunruname,
companycode = :companycode, balhangcode = :balhangcode,
balhaenggigwan = :balhaenggigwan, bojungcode = :bojungcode,
bojungrank = :bojungrank, bojungname = :bojungname,
saupjacode = :saupjacode, beobincode = :beobincode,
balhaengrank = :balhaengrank, gongsagb = :gongsagb, jasanmovegb = :jasanmovegb
where StandCode = :Standcode;
}
Fetch Acur :standcode, :standkorname, :balhaengilja, :machulilja, :mangiilja, :couponiyul,
:balhaengiyul, :halinyul, :ijagyesangb, :ijagyesangigan, :ijahusungb, :gwasegb,
:sinyongcode, :sinyongrank, :byunrucode, :byunruname, :companycode, :balhangcode,
:balhaenggigwan, :bojungcode, :bojungrank, :bojungname, :saupjacode, :beobincode,
:balhaengrank, :gongsagb, :jasanmovegb;
]
close Acur;
return p_Date;
end Procedure;
|