Home » SQL & PL/SQL » SQL & PL/SQL » ORA-06502: PL/SQL: numeric or value error using Bulk (Oracle 10g)
ORA-06502: PL/SQL: numeric or value error using Bulk [message #296113] |
Thu, 24 January 2008 11:47  |
amorphous4u
Messages: 34 Registered: December 2007 Location: Boston, US
|
Member |
 
|
|
ORA-06502: PL/SQL: numeric or value error
I 'm getting the above-referenced runtime error; dynamic SQL, fetching into a set of nested tables using BULK COLLECT. Can 't find anything in docs or on MetaLink or Google;Is due
to exceeding array size? I have tried LIMIT clause in FETCH ... BULK COLLECT INTO, but no luck.
Anyone familiar with this error please guide me.
I have attached the peice of code as file attachment.
Thanks and Regards,
Amit
-
Attachment: Code.sql
(Size: 1.34KB, Downloaded 1274 times)
[Updated on: Thu, 24 January 2008 11:50] Report message to a moderator
|
|
|
|
|
Re: ORA-06502: PL/SQL: numeric or value error using Bulk [message #297626 is a reply to message #296183] |
Fri, 01 February 2008 16:27   |
amorphous4u
Messages: 34 Registered: December 2007 Location: Boston, US
|
Member |
 
|
|
Hi,
I am attaching the code as below:
FUNCTION getTopUserGroupsPerFirm(v_FirmGUID IN VARCHAR, v_ContentSet IN VARCHAR, d_StartDate IN DATE, d_EndDate IN DATE)
RETURN CLOB
IS
TYPE data_curs_tab IS TABLE OF SYS.XMLTYPE; -- Added for declaring XMLTYPE Datatype
t_data_val data_curs_tab; --Variable for data_curs_tab
CURSOR data_curs IS
SELECT XMLForest(ut.user_group_guid as "UserGroupGUID",ut.usergroupname as "UserGroupName", Count(*) as "NumOfTransactions", SUM(ut.internal_price) as "DollarsSpent") as xml_row
FROM usertransaction ut
WHERE ut.firm_guid = v_firmGuid
AND (EVENT_DATETIME between d_StartDate and d_EndDate )
AND ut.content_type = v_ContentSet
GROUP by ut.user_group_guid,ut.usergroupname
ORDER BY SUM(ut.internal_price) DESC;
v_result CLOB;
v_nodename VARCHAR(64);
v_count NUMBER;
BEGIN
v_nodename := 'TopUserGroups_' || v_ContentSet;
OPEN data_curs;
FETCH data_curs bulk collect INTO t_data_val;
CLOSE data_curs;
FOR i IN t_data_val.first..t_data_val.last LOOP
v_result := v_result
|| '<UserGroup>'
|| t_data_val(i).getClobVal()
|| '</UserGroup>';
END LOOP;
RETURN '<' || v_nodename || '>' || v_result || '</' || v_nodename || '>';
EXCEPTION
WHEN OTHERS THEN
log_oracle_error(SQLCODE,SQLERRM,'Function UsageSummary_Test.getTopUserGroupsPerFirm throws an Exception',SYSDATE,NULL);
RETURN '';
END;
This is the function present in the Package which is throwing exception as
ORA-06502: PL/SQL: numeric or value error
Can you please help me out?
Thanks and Regards,
Amit Verma
|
|
|
|
|
Re: ORA-06502: PL/SQL: numeric or value error using Bulk [message #297637 is a reply to message #297634] |
Fri, 01 February 2008 20:16   |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
You need to test one thing at a time, so that you can narrow down where the error is coming from. You need to test it from SQL*Plus, not Toad, so that you know that it is not something with Toad that is causing the error. You need to test it without the exception section, by commenting it out, so that you know that it is not the autonomous program in the exception section that is causing the problem. If you do all of that and still get the error, then you will get a message that shows at exactly what point on what line the error is occuring, so that you know what to look for. Once again, this is a common error, that is usually caused by selecting the result into a varchar2 variable, instead of a clob. So, what data type are you selecting the result into? Once again, you need to read and follow the forum guidelines, and post a copy and paste of the run of compilation and execution of your code, including the line numbers, error number, and error message, and create table and insert statements for sample data, if you want help, otherwise you are on your own and any future posts will likely be ignored.
|
|
|
|
Re: ORA-06502: PL/SQL: numeric or value error using Bulk [message #297996 is a reply to message #297638] |
Mon, 04 February 2008 08:17   |
amorphous4u
Messages: 34 Registered: December 2007 Location: Boston, US
|
Member |
 
|
|
I cannot use count here as the table is very bulky...and it takes atleast 5 minutes to complete one count check and this function will be called atleast 8 times in one run.
This is the run from the SQL* Plus
SQL> set serveroutput on;
SQL> CREATE OR REPLACE FUNCTION getTopUserGroupsPerFirm(v_FirmGUID IN VARCHAR, v_ContentSet IN VARCHAR, d_StartDate IN DATE, d_EndDate IN DATE)
2 RETURN CLOB
3 IS
4 TYPE data_curs_tab IS TABLE OF SYS.XMLTYPE; -- Added for declaring XMLTYPE Datatype
5
6 t_data_val data_curs_tab; --Variable for data_curs_tab
7
8 CURSOR data_curs IS
9 SELECT XMLForest(ut.user_group_guid as "UserGroupGUID",ut.usergroupname as "UserGroupName", Count(*) as "NumOfTransactions", SUM(ut.internal_price) as "DollarsSpent") as xml_row
10 FROM usertransaction ut
11 WHERE ut.firm_guid = v_firmGuid
12 AND (EVENT_DATETIME between d_StartDate and d_EndDate )
13 AND ut.content_type = v_ContentSet
14 GROUP by ut.user_group_guid,ut.usergroupname
15 ORDER BY SUM(ut.internal_price) DESC;
16 --data_val data_curs%ROWTYPE;-- Commented as not required after change.
17 v_result CLOB;
18 v_nodename CLOB;
19
20 BEGIN
21 v_nodename := 'TopUserGroups_' || v_ContentSet;
22 -- Change for Optimization by Amit Verma on Dec 31, 2007 Starts
23 -- Below code is commented for Optimization Change
24 /*FOR data_val IN data_curs
25 LOOP
26 v_result := v_result
27 || '<UserGroup>'
28 || data_val.xml_row.getClobVal()
29 || '</UserGroup>';
30 END LOOP;*/
31 -- Below Code is introduced for Optimization
32 OPEN data_curs;
33 FETCH data_curs bulk collect INTO t_data_val;
34 CLOSE data_curs;
35
36 FOR i IN t_data_val.first..t_data_val.last LOOP
37 v_result := v_result
38 || '<UserGroup>'
39 || t_data_val(i).getClobVal()
40 || '</UserGroup>';
41 IF v_result IS NULL THEN
42 v_result := '';
43 END IF;
44 END LOOP;
45
46 RETURN '<' || v_nodename || '>' || v_result || '</' || v_nodename || '>';
47 -- Change for Optimization by Amit Verma on Dec 31, 2007 Ends
48 --EXCEPTION
49 --WHEN OTHERS THEN
50 --log_oracle_error(SQLCODE,SQLERRM,'Function UsageSummary_Test.getTopUserGroupsPerFirm throws an Exception',SYSDATE,NULL);
51 -- RETURN '';
52 END;
53 /
Function created.
SQL> select getTopUserGroupsPerFirm('{20A626BA-D648-4C15-B772-7307F904E768}','FilingsUsage',to_date('10/27/2005','mm/dd/yyyy'),to_date('10/28/200 5','mm/dd/yyyy'))
2 from dual;
ERROR:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "BANKDEV.GETTOPUSERGROUPSPERFIRM", line 36
no rows selected
Thanks and Regards,
Amit
|
|
|
Re: ORA-06502: PL/SQL: numeric or value error using Bulk [message #298005 is a reply to message #297996] |
Mon, 04 February 2008 09:30   |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
I think this could be your error i am not sure but still I thought it's worth a try.
Search for limit clause. By the look of it you are collecting the entire result of your cursor into the variable which is not a good way of doing it unless and until you are fetching only few thousand still I would like to see a limit clause in your bulk collect and loop around it. It's the ideal way of processing.
HTH
Regards
Raj
|
|
|
|
|
Goto Forum:
Current Time: Thu Jun 19 18:18:52 CDT 2025
|