473,487 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Rewrite query using bulk collect to improve performance

3 New Member
Hi,

I re-write a query and used bulk collect to improve the performance of the batch process. The query below has NO compile error but when execute query there is error 'ORA-01403: no data found.'

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PROCEDURE PROCESS_ANGKASA(REF_NO varchar2)is
  2. v_cntr_code varchar2(16);
  3. v_receipt_code varchar2(3);
  4. start_time number;
  5. end_time number; 
  6. receipt_date date; 
  7. receipt_no varchar2(50);
  8. c_receipt_no varchar2(30);
  9.  
  10. --JOIN IN CURSOR
  11. /* cursor cur_angkasa(ref_no varchar2) is 
  12. select p.c_client_code, p.n_seq_no, x_employer_no, p.x_employee_no,
  13. p.x_receipt_code, p.a_amt_recd, p.x_deduction_month,p.x_nric_old,a.angkasa_ic,a.type 
  14. into l_angkasa
  15. from pp_angkasa_receipt_dets p 
  16. JOIN angkasa a
  17. on p.c_client_code = a.angkasa_ic
  18. --where c_angkasa_ref_no = ref_no
  19. where c_angkasa_ref_no = 'BP22868'
  20. and p.n_seq_no = a.sequence_no; */
  21.  
  22. cursor cur_angkasa(ref_no varchar2) is 
  23. select c_client_code, n_seq_no, x_employer_no, x_employee_no, 
  24. x_receipt_code, a_amt_recd, x_deduction_month,x_nric_old
  25. from pp_angkasa_receipt_dets 
  26. where c_angkasa_ref_no = 'BP22868';
  27.  
  28. TYPE cur_angkasa_type IS TABLE OF cur_angkasa%ROWTYPE; 
  29. rec1 cur_angkasa_type; 
  30. recl cur_angkasa%ROWTYPE; 
  31.  
  32. Begin 
  33.  
  34. receipt_date := sysdate;
  35. receipt_no :='HQ1234'; 
  36.  
  37. Open cur_angkasa(ref_no); 
  38. DBMS_OUTPUT.PUT_LINE('TESTING BULK COLLECT'); 
  39. Fetch cur_angkasa bulk collect into rec1 limit 100; 
  40. For i in 1..rec1.count 
  41. loop 
  42. Dbms_output.put_line('In the Loop'); 
  43. Dbms_output.put_line (recl.c_client_code); -- no data 
  44. select c_cntr_code,type--error line51
  45. into v_cntr_code, v_receipt_code 
  46. from angkasa 
  47. where angkasa_ic = recl.c_client_code 
  48. and sequence_no = recl.n_seq_no; 
  49.  
  50. Exit when cur_angkasa%notfound; 
  51. Dbms_output.put_line ('End of the Loop');
  52.  
  53. if nvl(recl.a_amt_recd,0) <> 0 then 
  54. insert into receipt_info_all(c_cntr_code,c_receipt_no,d_receipt_date,a_receipt_amt,x_receipt_type,x_lastupd_user,x_lastupd_prog,x_lastupd_inftim)
  55. values (v_cntr_code,receipt_no,receipt_date,recl.a_amt_recd,v_receipt_code,user,'PREM_PROC',to_char(get_control_date,'dd/mm/rr hh24:mi:ss')); 
  56. end if; 
  57.  
  58. end loop;
  59. end;
  60.  

/*---------RESULTS--------- */
14:00:05 SQL> exec PROCESS_ANGKASA('BP22868');
TESTING BULK COLLECT
In the Loop
begin PROCESS_ANGKASA('BP22868'); end;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "PRODUCTION.PROCESS_ANGKASA", line 51
ORA-06512: at line 1


real: 94
14:00:06 SQL>

*END ---------ERROR --------- */

Please guide me to resolve the above problem.

Thanks & Regards,
Mar 26 '08 #1
3 3624
Saii
145 Recognized Expert New Member
handle the error using exception block.
Mar 26 '08 #2
oravm
3 New Member
Thanks Saii,

Added exception .. Below is the changes.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Begin 
  3.     Open cur_angkasa(ref_no); 
  4.     Loop
  5.     Fetch cur_angkasa BULK COLLECT into rec1 limit 100; 
  6.       For i in 1..rec1.count
  7.         Loop
  8.              SELECT c_cntr_code,TYPE
  9.               INTO v_cntr_code, v_receipt_code 
  10.               FROM angkasa 
  11.               WHERE angkasa_ic = rec1.c_client_code 
  12.                AND sequence_no = rec1.n_seq_no; 
  13.  
  14. IF NVL(recl.a_amt_recd,0) <> 0 Then 
  15.             INSERT INTO receipt_info_all(c_cntr_code,c_receipt_no,d_receip    t_date,a_receipt_amt,x_receipt_type,x_lastupd_user  ,x_lastupd_prog,x_lastupd_inftim)
  16.         VALUES (v_cntr_code,receipt_no,receipt_date,rec1.a_amt_re   cd,v_receipt_code,USER,'PREM_PROC',TO_CHAR(get_con  trol_date,'dd/mm/rr hh24:mi:ss')); 
  17.       END IF; 
  18.      End Loop;
  19.  EXIT WHEN cur_angkasa%notfound;
  20. END LOOP;
  21. exception
  22.  WHEN OTHERS THEN
  23.         dbms_output.put_line(SQLCODE || SQLERRM);
  24. END;
  25.  
  26.  
regards,
Vijaya
Mar 29 '08 #3
amitpatel66
2,367 Recognized Expert Top Contributor
Oravm,

Please remember to use [code] tags when ever you post any source code in forum.

For more details on code tags, check here
Mar 29 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7035
by: Diego | last post by:
HI, I'm trying yo improve the performance of the following piece of code. Here I'm archiving Items that are done processing to Archive Tables. I believe that if I use BULK INSERTS/SELECTS/UPDATES...
3
2768
by: gizmo | last post by:
I have a stored procedure that queries a database using a Select statement with some inner joins and conditions. With over 9 million records it takes 1 min 36 sec to complete. This is too slow...
9
4206
by: adi | last post by:
Hi all, Hope there is a quick fix for this: I am inserting data from one table to another on the same DB. The insert is pretty simple as in: insert into datatable(field1, field2, field3)...
0
1083
by: Pioneer | last post by:
HI, We are using BI software on Datawarehouse for reporting purpose. In that we had some performance realted issues. So the only solution to that was cerating indexes as per the requirements....
8
1968
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
9
2020
by: maxzsim via SQLMonster.com | last post by:
Hi, I am using MS Access as the front end and it's using ODBC link to connect to the backend tables residing at SQL SERVER. I have some queries that are doing some calculation and the time...
1
2874
by: devmiral | last post by:
Hello every one I trying simple bulk collect , it is giving me an error in oracle 9i, i wroe as per book and on the web deatils about bulk collect declare type emp_type is table of emp%rowtype;...
35
9297
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
0
5506
debasisdas
by: debasisdas | last post by:
We can fetch from a cursor into one or more collections: DECLARE TYPE NameList IS TABLE OF employees.last_name%TYPE; TYPE SalList IS TABLE OF employees.salary%TYPE; CURSOR c1 IS SELECT...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.