CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2271|Reply: 7

data missing - PL/SQL

[Copy link]
Post time 21-3-2007 02:56 PM | Show all posts |Read mode
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?
Reply

Use magic Report


ADVERTISEMENT


Post time 21-3-2007 05:22 PM | Show all posts
bagi entire pl/sql code
statement cam tu je camne nak check...
Reply

Use magic Report

Post time 21-3-2007 06:52 PM | Show all posts
dan pakai database aper...
Reply

Use magic Report

 Author| Post time 21-3-2007 11:30 PM | Show all posts
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');
Reply

Use magic Report

 Author| Post time 21-3-2007 11:35 PM | Show all posts
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
Reply

Use magic Report

Post time 22-3-2007 01:54 AM | Show all posts
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

Reply

Use magic Report

Follow Us
 Author| Post time 22-3-2007 10:37 AM | Show all posts
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?
Reply

Use magic Report

Post time 22-3-2007 11:44 AM | Show all posts
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..
Reply

Use magic Report


ADVERTISEMENT


You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

29-12-2024 01:31 PM GMT+8 , Processed in 1.558422 second(s), 25 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list