Q&A

  • 저장시 update... 고수님들 좀 봐주세염...
저장 버튼을 눌렀을 경우 조회시 ORDR13MT라는 테이블에 INSERT되어있는 데이타들을 확인하고(SProc2-스토프로시저에서) 필요하지 않는 테이타들은 DELETE(Hist_Del쿼리에서)시켜 업데이트 시키려구 합니다...

아래에 첨부한것이 그 소스인데요~

프로그램이 계속 돌지않구 멈춰 있어염~

아무래두 UPDATE하는 부분에서 뭔가 이상이 있는것이 아닐까 싶은데...

COMMIT 이나 UPDATE에 대해 잘 알지 못해 이렇게 헤메고 있어염,,,

고수님들 제발좀 도와주세염...

감사감사~ (참고.. 스토어프로시저도 참고로 맨~ 아래에 첨부합니다.. )



procedure TForm1.BtnPostClick(Sender: TObject);

begin

If BtnPost.Enabled <> True Then Exit;



ORDR13MT.Edit;

ORDR13MT.Post;

ORDR13MT.CommitUpdates;





With SProc2 do begin

ParamByName('P_NO_BUYER').AsString := eOR_NO1.Text;

ParamByName('P_NO_YEAR' ).AsString := eOR_NO2.Text;

ParamByName('P_NO_SEQ' ).AsFloat := eOR_NO3.Value;

Execproc;

End;



With Hist_Del do begin

ParamByName('P_NO_BUYER').AsString := eOR_NO1.Text;

ParamByName('P_NO_YEAR' ).AsString := eOR_NO2.Text;

ParamByName('P_NO_SEQ' ).AsFloat := eOR_NO3.Value;

Execsql;

End;



// Close Open 해도 원위치 찾기

With MQuery do begin

DisableControls;

Close;

Open;

EnableControls;

end;



User_Handle(Panel4.Enabled);

DBGrid1.SetFocus;

ORDR13MT.Refresh;

end;







***스토어프로시저** (SProc2)

create or replace procedure ordrpr17(p_no_buyer in varchar2,

p_no_year in varchar2,

p_no_seq in number)

is



g_read_cnt number(01); /* Read Count */

g_order_qty number(7,2); /* Order 수량 */





Cursor C1 is Select order_no_buyer, order_no_year, order_no_seq,

pattern_1, pattern_2, comb_no,

fabric_code, sum(nvl(ship_qty,0)) ship_qty

From ordr12mt

Where order_no_buyer = p_no_buyer

And order_no_year = p_no_year

And order_no_seq = p_no_seq

Group by order_no_buyer, order_no_year, order_no_seq,

pattern_1, pattern_2, comb_no,

fabric_code;



C1_Rec c1%rowtype;

begin



Open C1;

Loop



Fetch C1 into C1_Rec.order_no_buyer, C1_Rec.order_no_year, C1_Rec.order_no_seq,

C1_Rec.pattern_1, C1_Rec.pattern_2, C1_Rec.comb_no,

C1_Rec.fabric_code, C1_Rec.ship_qty;

Exit When C1%NotFound;





g_read_cnt := 0;



begin

select nvl(order_qty,0)

into g_order_qty

from ordr13mt

Where order_no_buyer = C1_Rec.order_no_buyer

And order_no_year = C1_Rec.order_no_year

And order_no_seq = C1_Rec.order_no_seq

And pattern_1 = C1_Rec.pattern_1

And pattern_2 = C1_Rec.pattern_2

And comb_no = C1_Rec.comb_no

And fabric_code = C1_Rec.fabric_code;

Exception

When others then

g_order_qty := 0;

end;





begin

select count(*)

into g_read_cnt

from ordr13mt

Where order_no_buyer = C1_Rec.order_no_buyer

And order_no_year = C1_Rec.order_no_year

And order_no_seq = C1_Rec.order_no_seq

And pattern_1 = C1_Rec.pattern_1

And pattern_2 = C1_Rec.pattern_2

And comb_no = C1_Rec.comb_no

And fabric_code = C1_Rec.fabric_code;

Exception

When others then

g_read_cnt := 0;

end;



if g_read_cnt > 0 then

begin

Update Ordr13mt

set ship_tot_qty = C1_Rec.ship_qty,

ship_jan_qty = nvl(g_order_qty,0) - C1_Rec.ship_qty

Where order_no_buyer = C1_Rec.order_no_buyer

and order_no_year = C1_Rec.order_no_year

and order_no_seq = C1_Rec.order_no_seq

and pattern_1 = C1_Rec.pattern_1

and pattern_2 = C1_Rec.pattern_2

and comb_no = C1_Rec.comb_No

and fabric_code = C1_Rec.fabric_code;

Exception

When Others then Null;

end;

end if;



End Loop;

Close C1;



Commit;



end;



1  COMMENTS
  • Profile
    최혜룡 2001.05.22 09:08
    고생많네요



    걸리는 부분이 있긴 한데..

    한번 Test나 해보시죠

    방법은

    ORDR13MT.Close; <-- 추가

    With SProc2 do begin

    ParamByName('P_NO_BUYER').AsString := eOR_NO1.Text;

    ParamByName('P_NO_YEAR' ).AsString := eOR_NO2.Text;

    ParamByName('P_NO_SEQ' ).AsFloat := eOR_NO3.Value;

    Execproc;

    End;

    ORDR13MT.Open; <-- 추가



    그리고 Del_His 실행부분을 주석처리하세요 (실행하지 못하게)

    다음에는 DEL_HIS안의 DELETE문을

    PL/SQL Procedure에 추가하세요

    Close C1;

    Commit;

    ..... <--- 요기에 DELETE 추가

    .....

    Commit; <--- 추가













    짱아 wrote:

    > 저장 버튼을 눌렀을 경우 조회시 ORDR13MT라는 테이블에 INSERT되어있는 데이타들을 확인하고(SProc2-스토프로시저에서) 필요하지 않는 테이타들은 DELETE(Hist_Del쿼리에서)시켜 업데이트 시키려구 합니다...

    > 아래에 첨부한것이 그 소스인데요~

    > 프로그램이 계속 돌지않구 멈춰 있어염~

    > 아무래두 UPDATE하는 부분에서 뭔가 이상이 있는것이 아닐까 싶은데...

    > COMMIT 이나 UPDATE에 대해 잘 알지 못해 이렇게 헤메고 있어염,,,

    > 고수님들 제발좀 도와주세염...

    > 감사감사~ (참고.. 스토어프로시저도 참고로 맨~ 아래에 첨부합니다.. )

    >

    > procedure TForm1.BtnPostClick(Sender: TObject);

    > begin

    > If BtnPost.Enabled <> True Then Exit;

    >

    > ORDR13MT.Edit;

    > ORDR13MT.Post;

    > ORDR13MT.CommitUpdates;

    >

    >

    > With SProc2 do begin

    > ParamByName('P_NO_BUYER').AsString := eOR_NO1.Text;

    > ParamByName('P_NO_YEAR' ).AsString := eOR_NO2.Text;

    > ParamByName('P_NO_SEQ' ).AsFloat := eOR_NO3.Value;

    > Execproc;

    > End;

    >

    > With Hist_Del do begin

    > ParamByName('P_NO_BUYER').AsString := eOR_NO1.Text;

    > ParamByName('P_NO_YEAR' ).AsString := eOR_NO2.Text;

    > ParamByName('P_NO_SEQ' ).AsFloat := eOR_NO3.Value;

    > Execsql;

    > End;

    >

    > // Close Open 해도 원위치 찾기

    > With MQuery do begin

    > DisableControls;

    > Close;

    > Open;

    > EnableControls;

    > end;

    >

    > User_Handle(Panel4.Enabled);

    > DBGrid1.SetFocus;

    > ORDR13MT.Refresh;

    > end;

    >

    >

    >

    > ***스토어프로시저** (SProc2)

    > create or replace procedure ordrpr17(p_no_buyer in varchar2,

    > p_no_year in varchar2,

    > p_no_seq in number)

    > is

    >

    > g_read_cnt number(01); /* Read Count */

    > g_order_qty number(7,2); /* Order 수량 */

    >

    >

    > Cursor C1 is Select order_no_buyer, order_no_year, order_no_seq,

    > pattern_1, pattern_2, comb_no,

    > fabric_code, sum(nvl(ship_qty,0)) ship_qty

    > From ordr12mt

    > Where order_no_buyer = p_no_buyer

    > And order_no_year = p_no_year

    > And order_no_seq = p_no_seq

    > Group by order_no_buyer, order_no_year, order_no_seq,

    > pattern_1, pattern_2, comb_no,

    > fabric_code;

    >

    > C1_Rec c1%rowtype;

    > begin

    >

    > Open C1;

    > Loop

    >

    > Fetch C1 into C1_Rec.order_no_buyer, C1_Rec.order_no_year, C1_Rec.order_no_seq,

    > C1_Rec.pattern_1, C1_Rec.pattern_2, C1_Rec.comb_no,

    > C1_Rec.fabric_code, C1_Rec.ship_qty;

    > Exit When C1%NotFound;

    >

    >

    > g_read_cnt := 0;

    >

    > begin

    > select nvl(order_qty,0)

    > into g_order_qty

    > from ordr13mt

    > Where order_no_buyer = C1_Rec.order_no_buyer

    > And order_no_year = C1_Rec.order_no_year

    > And order_no_seq = C1_Rec.order_no_seq

    > And pattern_1 = C1_Rec.pattern_1

    > And pattern_2 = C1_Rec.pattern_2

    > And comb_no = C1_Rec.comb_no

    > And fabric_code = C1_Rec.fabric_code;

    > Exception

    > When others then

    > g_order_qty := 0;

    > end;

    >

    >

    > begin

    > select count(*)

    > into g_read_cnt

    > from ordr13mt

    > Where order_no_buyer = C1_Rec.order_no_buyer

    > And order_no_year = C1_Rec.order_no_year

    > And order_no_seq = C1_Rec.order_no_seq

    > And pattern_1 = C1_Rec.pattern_1

    > And pattern_2 = C1_Rec.pattern_2

    > And comb_no = C1_Rec.comb_no

    > And fabric_code = C1_Rec.fabric_code;

    > Exception

    > When others then

    > g_read_cnt := 0;

    > end;

    >

    > if g_read_cnt > 0 then

    > begin

    > Update Ordr13mt

    > set ship_tot_qty = C1_Rec.ship_qty,

    > ship_jan_qty = nvl(g_order_qty,0) - C1_Rec.ship_qty

    > Where order_no_buyer = C1_Rec.order_no_buyer

    > and order_no_year = C1_Rec.order_no_year

    > and order_no_seq = C1_Rec.order_no_seq

    > and pattern_1 = C1_Rec.pattern_1

    > and pattern_2 = C1_Rec.pattern_2

    > and comb_no = C1_Rec.comb_No

    > and fabric_code = C1_Rec.fabric_code;

    > Exception

    > When Others then Null;

    > end;

    > end if;

    >

    > End Loop;

    > Close C1;

    >

    > Commit;

    >

    > end;

    >