|
erm,aku ada satu pertanyaan mengenai stored procedure yg aku buat ni..
bile aku run kan skrip ni, die menyebab kan data dalam database aku hilang.. huhu..
walhal aku takde letak statement delete pun..
boleh tak korg suggest ape sebabnye data tu hilang ye.. aku kasi contoh mcm kat bawah ni la..
a = 50, b =25
katakan a = a - b
so,sepatutnye.. hasil dia 25 jugakla kan.. tp result die tak menunjukkan ape2 nilai pada a tersebut...
anyone? ade idea tak? kenape boleh jadi mcm ni? |
|
|
|
|
|
|
|
bagi entire pl/sql code
statement cam tu je camne nak check... |
|
|
|
|
|
|
|
dan pakai database aper... |
|
|
|
|
|
|
|
Originally posted by shahnazz at 21-3-2007 05:22 PM
bagi entire pl/sql code
statement cam tu je camne nak check...
CREATE OR REPLACE Procedure namadatabase.storedprocedure
(
p_year in number,
p_ref in varchar2
)
IS
v_abc namadatabase.tablesatu.abc%type;
v_def namadatabase.tablesatu.def%type;
v_ref namadatabase.tablesatu.refi%type;
v_year namadatabase.tablesatu.year%type;
v_k_jb namadatabase.tablesatu.kjb%type;
v_gh namadatabase.tabledua.gh%type;
v_ij namadatabase.tabledua.ij%type;
v_kl namadatabse.tabletiga.kl%type;
v_mn namadatabase.tabletiga.mn%type;
v_op namadatabase.tabletiga.op%type;
v_a_seq namadatabase.tabletiga.a_seq%type;
BEGIN
select abc,def into v_abc,v_def from namadatabase.tablesatu
where refi = p_ref and year = p_year;
select gh,ij into v_gh,v_ij from namadatabase.tabledua
where kjb = v_k_jb and year = v_year ;
Begin
select kl,mn into v_kl,v_mn from namadatabase.tableTiga
where kjb = v_k_jb and year = v_year;
Exception
when others then
my_sqlcode := sqlcode;
my_sqlerrm := substr(sqlerrm, 1, 100);
insert into d_error_log (sqlcode, sqlerrm, error_date, module_name, error_detail)
values (my_sqlcode, my_sqlerrm, sysdate, 'No data', 'found ' || v_abc);
commit;
End;
insert into namadatabase.tablesatu (abc,def,refi,year,kjb,kl,mn)
values (v_abc,v_def,v_ref,v_year,v_k_j_b,(v_kl - v_op),(v_mn - v_op)) ;
update namadatabase.tabletiga set
kl = v_kl - v_op,
mn = v_mn - v_op
where a_seq = v_a_seq;
commit;
Exception
when others then
my_sqlcode := sqlcode;
my_sqlerrm := substr(sqlerrm, 1, 100);
insert into d_error_log (sqlcode, sqlerrm, error_date, module_name, error_detail)
values (my_sqlcode, my_sqlerrm, sysdate, 'No data', 'found ' || v_abc);
commit;
END ;
exec namadatabase.storedprocedur(2007, '12AJK'); |
|
|
|
|
|
|
|
Originally posted by stingbeh at 21-3-2007 06:52 PM
dan pakai database aper...
database gune oracle..
so, skrip ni involved 3 table dari database yg same...
erm.. sepatutnye bile buat insert value, field pada kl dan mn tu akan beri nilai....
(fyi, kl dan mn ade dalam tablesatu dan tabletiga)
tp bile buat select statement, takdelah plak nilai tu... huhu
btw, thank you in advance |
|
|
|
|
|
|
|
Originally posted by ammameiya at 2007321 11:30 PM
select gh,ij into v_gh,v_ij from namadatabase.tabledua
where kjb = v_k_jb and year = v_year ;
v_year kau takde value (sebenarnye kene pakai p_year kan?)
sama seperti di kes di bawah jugak
Originally posted by ammameiya at 2007321 11:30 PM
select kl,mn into v_kl,v_mn from namadatabase.tableTiga
where kjb = v_k_jb and year = v_year;
Originally posted by ammameiya at 2007321 11:30 PM
update namadatabase.tabletiga set
kl = v_kl - v_op,
mn = v_mn - v_op
where a_seq = v_a_seq;
waktu kat sini v_a_seq ko tak assign aper2 value jugak ,
jadi dia tak dapat buat update pasal takde value a_seq yg sama dengan v_a_seq
so make sure all variable tue ader value
[ Last edited by stingbeh at 22-3-2007 02:03 AM ] |
Rate
-
1
View Rating Log
-
|
|
|
|
|
|
|
select gh,ij into v_gh,v_ij from namadatabase.tabledua
where kjb = v_k_jb and year = v_year ;
year tu aku comparekan dengan v_year dr tablesatu
update namadatabase.tabletiga set
kl = v_kl - v_op,
mn = v_mn - v_op
where a_seq = v_a_seq;
untuk yg ni plak aku comparekan a_seq dgn v_a_seq.. memanf kena letak value jugak ke?
tpkan yang aku musykil tu..
kenapa value dalam kl dan mn tu boleh hilang ye lepas aku run kan skrip ni?
kalaulah dia tak update table tu.. for sure value lama ade lagi kan?
betul ke? |
|
|
|
|
|
|
|
macam mana ko boleh comparekan dengan tablesatu sedangkan value dia tak diset?
v_year amik value dari mane?
tentang update tue plak, aku takde penjelasan.. |
|
|
|
|
|
|
| |
|