I have a stored procedure which is executing a dynamic select query. The query string is large. The following is the stored procedure
create or replace procedure My_SP ( procRefCursor out sys_refcursor, --My other input variables here ) is dynSqlComplete varchar2(8000) := 'n/a'; begin dynSqlComplete := 'Large query here'; open procRefCursor for dynSqlComplete; end;
When I run this sp it shows the following error
ORA-00600: internal error code, arguments: [qcscbAddToSelLists], [], [], [], [], [], [], [], [], [], [], []
so I reduced the size of dynSqlComplete variable to varchar2(5000) and then ran the stored procedure. I got the following error:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
I have tried many things in vain and also I do not want to add them here because it will misguide.
-- EDIT -- 6 Jun 2012
Hi All,
I was able to pin point the problem but I am not yet able to solve it. I tried to run the query part by part and I found the query which was throwing an error. It contained START WITH and when i commented it the query started to work. I have given the code below and commented out the code which is giving error.
SELECT RowNum AS RowNumber1,
GR.*,
--LEVEL AS LineageLvl,
VDE.*
FROM
(SELECT *
FROM group_relations left outer join relation_classifier_instances RC on
rc.relation_id = group_relations.Group_relation_id WHERE group_relation_type_id IN
(19,20,32,38,42,43) and (rc.relation_id is null)
) GR
LEFT OUTER JOIN Vendor_Feed_data_elements VDE
ON GR.Group_Relation_Type_Id = 19
AND GR.Primary_GroupField_Id = VDE.Vendor_Data_Element_Id
/* Code which is giving the error
START WITH
(
VDE.Vendor_Data_Element_Id IS NOT NULL )
CONNECT BY nocycle prior GR.RELATED_GROUPFIELD_ID = GR.PRIMARY_GROUPFIELD_ID*/
dbms_output.put_line( dynSqlComplete )before opening the cursor and then try to execute that statement manually, does the statement work? If so, then you've narrowed the problem down to the call toOPEN. If not, the problem is in the SQL statement itself or the SQL statement that you're generating is malformed. - Justin Caveset serveroutput onin order to tell SQLPlus to create a buffer fordbms_outputto write to and to read from the buffer and display the data. If you can't even print the word "hi", it implies that your tool hasn't been configured to display the output ofdbms_output. You could also write the SQL statement to a database table and view the query after your code runs. - Justin Cave