Home » SQL & PL/SQL » SQL & PL/SQL » BULK COLLECT FORALL (Oracle 10g)
BULK COLLECT FORALL [message #565989] |
Mon, 10 September 2012 05:58  |
 |
bhibe_17
Messages: 24 Registered: July 2012
|
Junior Member |
|
|
Hi,
I'm trying to create a procedure but it's giving me errors:
16/3 PL/SQL: ORA-00942: table or view does not exist
4/2 PL/SQL: SQL Statement ignored
3/9 PLS-00341: declaration of cursor 'S_CUR' is incomplete or malformed
63/3 PL/SQL: Item ignored
69/33 PLS-00597: expression 'S_ARRAY' in the INTO list is of wrong type
69/3 PL/SQL: SQL Statement ignored
72/15 PL/SQL: ORA-00942: table or view does not exist
72/3 PL/SQL: SQL Statement ignored
I don't get why its giving table or view does not exists, because when I just execute the SELECT statement, it returned records. weird...
here's my procedure:
create or replace procedure proc_jrp_d_old_77a
as
cursor s_cur is
select /*+ ALL_ROWS */&vtabdate,
cd.cb_cardholder_no,
ac.user_id,
au.dep_name,
aud_timestamp,
field_name,
field_desc,
old_value,
new_value
from cp_audcpm ac,
cp_csttbl_&vtabdate ct,
cp_crdtbl_&vtabdate cd,
ACL_USER au
where cd.cb_idno = ct.cb_customer_idno
AND cd.cb_id_type = ct.cb_id_type
and key_value = ct.cb_id_type || '|' || ct.cb_customer_idno
and key_value = cd.cb_id_type || '|' || cd.cb_idno
and ac.user_id=au.user_id
and au.dep_name<>'Membership'
and table_name = 'CP_CSTTBL'
and (operation = 'UPDATE' or operation = 'update')
and substr(aud_timestamp,1,4)||substr(aud_timestamp,6,2)||substr(aud_timestamp,9,2)=&vrepdate
and field_name in ('CB_HOME_ADDR1',
'CB_HOME_ADDR2',
'CB_HOME_ADDR3',
'CB_HOME_ADDR4',
'CB_HOME_ADDR5',
'CB_HOME_CITY',
'CB_HOME_STATE',
'CB_HOME_CNTRY_CD',
'CB_HOME_POSTCODE',
'CB_CO_ADDR1',
'CB_CO_ADDR2',
'CB_CO_ADDR3',
'CB_CO_ADDR4',
'CB_CO_ADDR5',
'CB_CO_CITY',
'CB_CO_STATE',
'CB_CO_CNTRY_CD',
'CB_CO_POSTCODE',
'CB_ALT1_BILL_ADDR1',
'CB_ALT1_BILL_ADDR2',
'CB_ALT1_BILL_ADDR3',
'CB_ALT1_BILL_ADDR4',
'CB_ALT1_BILL_ADDR5',
'CB_ALT1_BILL_CITY',
'CB_ALT1_BILL_STATE',
'CB_ALT1_BILL_CNTRY_CD',
'CB_ALT1_BILL_ADDR_POSTCODE',
'CB_ALT2_BILL_ADDR1',
'CB_ALT2_BILL_ADDR2',
'CB_ALT2_BILL_ADDR3',
'CB_ALT2_BILL_ADDR4',
'CB_ALT2_BILL_ADDR5',
'CB_ALT2_BILL_CITY',
'CB_ALT2_BILL_STATE',
'CB_ALT2_BILL_CNTRY_CD',
'CB_ALT2_BILL_ADDR_POSTCODE')
order by 1, 4;
type d_old_77a_type is table of s_cur%rowtype;
s_array d_old_77a_type;
begin
open s_cur;
loop
fetch s_cur bulk collect into s_array limit 1000;
forall i in 1..s_array.count
insert into jrp_old_77a
values s_array(i);
exit when s_cur%notfound;
end loop;
close s_cur;
end;
/
this is my first time to use BULK COLLECT and FORALL that's why i'm not familiar with these syntax. any help is appreciated. thanks!
|
|
|
|
Re: BULK COLLECT FORALL [message #565995 is a reply to message #565989] |
Mon, 10 September 2012 06:20   |
 |
Michel Cadot
Messages: 68767 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
The problem as nothing to do with BULK COLLECT and FORALL.
Put all these lines in comment and you will have the same errors.
Use SQL*Plus and copy and paste your session like:
SQL> l
1 create or replace procedure proc_jrp_d_old_77a
2 as
3 cursor s_cur is
4 select /*+ ALL_ROWS */&vtabdate,
5 cd.cb_cardholder_no,
6 ac.user_id,
7 au.dep_name,
8 aud_timestamp,
9 field_name,
10 field_desc,
11 old_value,
12 new_value
13 from cp_audcpm ac,
14 cp_csttbl_&vtabdate ct,
15 cp_crdtbl_&vtabdate cd,
16 ACL_USER au
17 where cd.cb_idno = ct.cb_customer_idno
18 AND cd.cb_id_type = ct.cb_id_type
19 and key_value = ct.cb_id_type || '|' || ct.cb_customer_idno
20 and key_value = cd.cb_id_type || '|' || cd.cb_idno
21 and ac.user_id=au.user_id
22 and au.dep_name<>'Membership'
23 and table_name = 'CP_CSTTBL'
24 and (operation = 'UPDATE' or operation = 'update')
25 and substr(aud_timestamp,1,4)||substr(aud_timestamp,6,2)||substr(aud_timestamp,9,2)=&vrepdate
26 and field_name in ('CB_HOME_ADDR1',
27 'CB_HOME_ADDR2',
28 'CB_HOME_ADDR3',
29 'CB_HOME_ADDR4',
30 'CB_HOME_ADDR5',
31 'CB_HOME_CITY',
32 'CB_HOME_STATE',
33 'CB_HOME_CNTRY_CD',
34 'CB_HOME_POSTCODE',
35 'CB_CO_ADDR1',
36 'CB_CO_ADDR2',
37 'CB_CO_ADDR3',
38 'CB_CO_ADDR4',
39 'CB_CO_ADDR5',
40 'CB_CO_CITY',
41 'CB_CO_STATE',
42 'CB_CO_CNTRY_CD',
43 'CB_CO_POSTCODE',
44 'CB_ALT1_BILL_ADDR1',
45 'CB_ALT1_BILL_ADDR2',
46 'CB_ALT1_BILL_ADDR3',
47 'CB_ALT1_BILL_ADDR4',
48 'CB_ALT1_BILL_ADDR5',
49 'CB_ALT1_BILL_CITY',
50 'CB_ALT1_BILL_STATE',
51 'CB_ALT1_BILL_CNTRY_CD',
52 'CB_ALT1_BILL_ADDR_POSTCODE',
53 'CB_ALT2_BILL_ADDR1',
54 'CB_ALT2_BILL_ADDR2',
55 'CB_ALT2_BILL_ADDR3',
56 'CB_ALT2_BILL_ADDR4',
57 'CB_ALT2_BILL_ADDR5',
58 'CB_ALT2_BILL_CITY',
59 'CB_ALT2_BILL_STATE',
60 'CB_ALT2_BILL_CNTRY_CD',
61 'CB_ALT2_BILL_ADDR_POSTCODE')
62 order by 1, 4;
63 type d_old_77a_type is table of s_cur%rowtype;
64 s_array d_old_77a_type;
65
66 begin
67 open s_cur;
68 /*
69 loop
70 fetch s_cur bulk collect into s_array limit 1000;
71
72 forall i in 1..s_array.count
73 insert into jrp_old_77a
74 values s_array(i);
75
76 exit when s_cur%notfound;
77 end loop;
78 */
79 close s_cur;
80* end;
SQL> /
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE PROC_JRP_D_OLD_77A:
LINE/COL
---------------------------------------------------------------------------------
ERROR
------------------------------------------------------------------------------------------------------------------------
4/2
PL/SQL: SQL Statement ignored
14/13
PL/SQL: ORA-00933: SQL command not properly ended
Regards
Michel
|
|
|
|
|
|
Re: BULK COLLECT FORALL [message #566046 is a reply to message #566041] |
Tue, 11 September 2012 01:30  |
 |
Michel Cadot
Messages: 68767 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
1/ Privileges acquired from a role are not active in a procedure (unless you change the AUTHID option)
2/ Next time, please copy and paste your SQL*Plus session like I did.
Regards
Michel
|
|
|
Goto Forum:
Current Time: Tue Aug 26 11:36:37 CDT 2025
|