How to clear the Ref Cursor runtime error
Hello everyone,the code as follows
create or replace
procedure Country_sel(key in varchar2)
as
cc Res_RelcountryLan.countrycode%type;
len Res_Language.langname_en%type;
lid Res_Language.langid%type;
ab Res_Language.Abrivation%type;
type refcursorr is ref cursor;
cur refcursorr;
d_stmt varchar2(100);
begin
d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',
RL.Abrivation from Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId';
open cur for d_stmt;
loop
fetch cur into cc,lid,len,ab;
if cur%found then
dbms_output.put_line(cc||lid||len||ab);
else
exit;
end if;
end loop;
close cur;
commit;
end Country_sel;
When I run this code im gettingORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "RASOOL.COUNTRY_SEL", line 11
ORA-06512: at line 6
can you please help me get rid of this problem.thanking you,
Prakash
d_stmt varchar2(100);
Increase the size of d_stmt. Your an a larger string assignment
d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',RL.Abrivation from Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId';
The size of the string above is more than 100 characters.
Tags: Database
Similar Questions
-
help how to extract the ref cursor in the table field
Hello.
I have a query similar to the following:
Expecting to get several lines, I want this select this option to be in bulk sampled in a table variable nested (of another type of nested table) which is copied to an out parameter in a procedure. I have some doubts:select department_id, cursor (select employee_id from employees where department_id = d.department_id) from departments d
1 should. what I create the column in the inner nested table that will keep the result of the ref cursor? Ref cursor colunm? A sort of column Adrien?
2. If the column in the nested table inside that will keep the result of the ref cursor is another array, how can I write the result of the entire query in a single volume?
(I want to bulk collect everything in a single query, I know how to do with pl/sql do not inflate but using two nested for loops, that's what I try to avoid).
Thanks in advance.It would be simpler:
declare type dep_emp_list_tbl_type is table of sys.OdciVarchar2List; v_dep_emp_list_tbl dep_emp_list_tbl_type; v_dep_id_tbl sys.OdciNumberList; begin select department_id, cast(multiset(select employee_id from hr.employees where department_id = d.department_id) as sys.OdciVarchar2List) bulk collect into v_dep_id_tbl,v_dep_emp_list_tbl from hr.departments d; end; /
SY.
-
How to clear this type of runtime error
good day,
I'm migration procedures sql server to oracle procedures
I am trying to run tank (39) plsql function is the correct way which follows and if this path is correct I am
Run the error as
the screen output result:create or replace procedure Sel_subgroup(key in varchar2,gradename in varchar2) as gid res_grades.grade_id%type; gn res_grades.gradename_en%type; stid sub_topics.subtopic_id%type; stn sub_topics.subtopicname_en%type; cc res_grades.countrycode%type; estid exsub_topics.exsub_topics_id%type; estn exsub_topics.exsubtopicname_en%type; d_stmt varchar2(500); type ref_cursor is ref cursor; rc ref_cursor; begin d_stmt :='SELECT RG.Grade_ID,RG.Gradename_'||key||',ST.SubTopic_ID,ST.SubTopicname_'||key||', RG.CountryCode, Est.ExSub_Topics_ID, Est.ExSubTopicname_'||key||' from Res_Grades RG INNER JOIN Sub_Topics ST ON RG.Grade_Id= ST.Grade_ID INNER JOIN ExSub_Topics Est ON ST.SubTopic_ID = Est.Sub_Topics_Id Where Gradename_'||key||' = '''||gradename||''''; open rc for d_stmt; loop fetch rc into gid,gn,stid,stn,cc,estid,estn; if rc%found then dbms_output.put_line(gid||gn||stid||stn||cc||estid||estn); else exit; end if; end loop; close rc; commit; end Sel_subgroup;
Can u please help me,Connecting to the database rasool. Process exited. Disconnecting from the database rasool.
thanking you,
Prakashjeenesh sorry I am fresh I don't know it is case sensitive.i tried with "Pre - K" instead of "PRE - K" now, my code is working.sorry to bother guys
my code as follows...create or replace procedure Sel_subgroup(key in varchar2,gradename in varchar2,rc out sys_refcursor) as gid res_grades.grade_id%type; gn res_grades.gradename_en%type; stid sub_topics.subtopic_id%type; stn sub_topics.subtopicname_en%type; cc res_grades.countrycode%type; estid exsub_topics.exsub_topics_id%type; estn exsub_topics.exsubtopicname_en%type; d_stmt varchar2(500); begin d_stmt :='SELECT RG.Grade_ID,RG.Gradename_'||key||',ST.SubTopic_ID,ST.SubTopicname_'||key||', RG.CountryCode, Est.ExSub_Topics_ID, Est.ExSubTopicname_'||key||' from Res_Grades RG INNER JOIN Sub_Topics ST ON RG.Grade_Id= ST.Grade_ID INNER JOIN ExSub_Topics Est ON ST.SubTopic_ID = Est.Sub_Topics_Id Where Gradename_'||key||' = '''||gradename||''''; open rc for d_stmt; loop fetch rc into gid,gn,stid,stn,cc,estid,estn; dbms_output.put_line(gid||gn||stid||stn||cc||estid||estn); exit when rc%notfound; end loop; close rc; commit; end Sel_subgroup;
DECLARE KEY VARCHAR2(200); GRADENAME VARCHAR2(200); RC sys_refcursor; BEGIN KEY := 'en'; GRADENAME := 'Pre-K'; SEL_SUBGROUP( KEY => KEY, GRADENAME => GRADENAME, RC => RC ); /* Legacy output: DBMS_OUTPUT.PUT_LINE('RC = ' || RC); */ :RC := RC; --<-- Cursor END;
Thank you for all your responses guys
Prakash
-
How print/store in the ref cursor block pl/sql folder?
How print/store in the ref cursor block pl/sql folder?return to the SQL * the method I showed above:
SQL> create or replace procedure test (p_refcur out sys_refcursor) 2 is 3 begin 4 open p_refcur for select * from dual union all select * from dual; 5 end test; 6 / Procedure created. SQL> var r refcursor; SQL> begin 2 test(:r); 3 end; 4 / PL/SQL procedure successfully completed. SQL> print r; D - X X 2 rows selected.
-
How to start the view off of the ref cursor Oracle as input/output param
Hello world
We use JDev 11.1.2.3 WL 10.3.6 and Java 7.
We are at the beginning of our transition from Oracle Forms to ADF. We have a very large forms that uses many store procedures that have IN/OUT ref Cursor parameters and tables plsql. I tried to find information on best practices to achieve, but only seemed to find tutorials on SEO of the Oracle ref Cursor return functions. I hope we don't have to rewrite our code of database to work with ADF.
This is an example of a proc currently a block on a form based on directly
The ref cursor parameter is input/output to satisfy the way the form handles this type of paradigm.
ADF we want I hope to reuse these procs existing (without the need to wrap/overload them) on the basis of the display objects.
Example:
/ * my record type which houses the information I want to go back * /.
TYPE rec_hist_vacpac_status IS RECORD)
rec_order NUMBER (5),
rec_rownum NUMBER (5),
return_column SAM_VACPAC.vacpac_status%TYPE,
rec_login_id SAM_VACPAC.ins_user%TYPE,
status_date SAM_VACPAC.status_date%TYPE
);
/ * Sets the ref cursor type * /.
TYPE lcur_hist_vacpac_status IS REF CURSOR;
/ * This is a procedure that would take some info link go / return
Return the ref cursor of this information as an in / out * /.
PROCEDURE prc_myinfo_refcur)
pnum_identify_seq_id in NUMBERS
pcur_myinfo IN OUT lcur_hist_vacpac_status);
Can anyone point me in the right direction on documentation on this?
Thank you!
Hi Cemerson:
See this example:
- 1. create a TYPE as an object
CREATE OR REPLACE
TYPE GOTYOB_EQUI
AS AN OBJECT
(
CDELEM VARCHAR2 (50).
TIELEM VARCHAR2 (2)
);
- 2. create a TABLE TYPE AS
CREATE OR REPLACE
TYPE GOTYTA_EQUI
AS THE GOTYOB_EQUI TABLE;
- 3 create a function, it returns the TYPE of the TABLE
FUNCTION fn_equiposarriba)
pa_cdelem IN VARCHAR2,
pa_nucomp in NUMBERS
pa_anperi in NUMBERS
pa_meperi in NUMBERS
)
Gotyta_equi RETURN PIPELINED IS
CURSOR trae_equimani (va_cdelem VARCHAR2) IS
SELECT cdelem, tielem, cdelempadr,
(SELECT cdequi
Of evm_alim
WHERE anperi = eq.anperi
AND meperi = eq.meperi
AND nucomp = eq.nucomp
AND cdalim = eq.cdalim) cdalim
Of evm_equimani eq
WHERE anperi = pa_anperi
AND meperi = pa_meperi
AND nucomp = pa_nucomp
AND cdelem = va_cdelem
AND cdelempadr <> cdelem
AND tielem <> 'A ';
equimani trae_equimani % ROWTYPE;
va_cdalim VARCHAR2 (100);
BEGIN
-Loading los equipos aguas arriba
WHILE equimani.cdelempadr IS NOT NULL LOOP
OPEN trae_equimani (equimani.cdelempadr);
equimani: = NULL;
SEEK trae_equimani INTO equimani;
CLOSE Trae_equimani;
IF equimani.cdelem IS NOT NULL THEN
PIPE ROW (gotyob_equi (equimani.cdelem, equimani.tielem));
END IF;
END LOOP;
RETURN;
END;
- 4 SQL Query with the help of the function... you can use this SQL in a display object
SELECT
*
Of
TABLE (gopq_eventos.fn_equiposarriba (' F-SCZ-043-103', '))
1,
2013,
6
)
)
Best regards, Marcelo
-
Fetch the Ref Cursor several times
create or replace PROCEDURE refcursor1 AS TYPE r_cursor IS REF CURSOR; rcv_emp r_cursor; TYPE rec_emp IS record ( empno NUMBER, ename VARCHAR2(20 CHAR), deptno number ); recv_emp rec_emp; recv_emp2 rec_emp; ------------------------------------------------------- PROCEDURE printemployeedetails AS BEGIN loop fetch rcv_emp INTO recv_emp; exit WHEN rcv_emp%notfound; dbms_output.put_line(recv_emp.empno||'-'||recv_emp.ename||'-'||recv_emp.deptno); END loop; END; ------------------------------------------------------- PROCEDURE printemployeedetails2(p_emp r_cursor) IS BEGIN loop fetch p_emp INTO recv_emp2; exit WHEN p_emp%notfound; dbms_output.put_line(recv_emp2.empno||'-'||recv_emp2.ename||'-'||recv_emp2.deptno); end loop; END; ------------------------------------------------------- BEGIN FOR i IN (SELECT deptno FROM dept order by deptno) loop OPEN rcv_emp FOR SELECT empno,ename,deptno FROM emp WHERE deptno=i.deptno; dbms_output.put_line(i.deptno); dbms_output.put_line('--------------------'); dbms_output.put_line('calling printemployeedetails'); printemployeedetails; dbms_output.put_line(' '); dbms_output.put_line('calling printemployeedetails2'); dbms_output.put_line(' '); printemployeedetails2(rcv_emp); CLOSE rcv_emp; END loop; end;
Output:
10 -------------------- calling printemployeedetails 7839-KING-10 7782-CLARK-10 7934-MILLER-10 calling printemployeedetails2 20 -------------------- calling printemployeedetails 7566-JONES-20 7788-SCOTT-20 7902-FORD-20 7369-SMITH-20 7876-ADAMS-20 calling printemployeedetails2 30 -------------------- calling printemployeedetails 7698-BLAKE-30 7499-ALLEN-30 7521-WARD-30 7654-MARTIN-30 7844-TURNER-30 7900-JAMES-30 calling printemployeedetails2 40 -------------------- calling printemployeedetails calling printemployeedetails2
Hi all
If I open a cursor once can I collect the elements of a cursor n times as above? I see one of these procedures to print the details, but not both.
Wonder why that I'm passing same ref cursor to a second procedure.
It doesn't throw me an error indicating that the elements of the ref cursor is already read.
Thank you.
Your condition is not clear. Cursor is a pointer. He points to the result set of your query. At the time wherever you collect once, it advances the pointer to the next line and so on. I wonder if the pointer can return to the previous line once you recovered.
-
How to clear the hard drive on my old iMac of 2008?
I have a 2008 iMac I want to recycle. How to clear the hard drive?
(What is PPC?)
PPC stands for Power PC. Is the name used to refer to the old Macs that uses a Motorola processor instead of Intel chips used today. To clear your old Mac follow the advice in this document from Apple... What to do before you sell or give away your Mac - Apple Support
-
Initialize the Ref Cursor to avoid ORA-01001: Invalid cursor
Hello
I write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.
Any help is greatly appreciated...
Thank you
Christinecad0227 wrote:
HelloI write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.
Any help is greatly appreciated...
Thank you
ChristineThe most appropriate way would be the caller to handle the situation. The caller must capture the exception of INVALID_CURSOR and do what is necessary.
Other suggestions like having a separate Pavilion or a model select all will lead the appellant to act to the particular situation, that slider is not being opened. What is the case with the exception of INVALID_CURSOR raised by oracle.
All the need for the appellant to do is manage the exception of INVALID_CURSOR and you should be good. And also INVALID_CURSOR is not a mistake, it's an exception that has a special meaning for her. In the case you sense it takes the condition when not together to return a cursor.
-
How to create a Ref cursor table
I have a proc that returns a Ref Cursor, what is the easiest way to create a table based on the return of the ref cursor?
declare
type rc is ref cursor;
p_data rc;
Start
call_my_proc (p_data);
: result: = p_data; ((- If I run this in TOAD I can see the data here, but I want to create a table based on it rather than showing)
end;
Thank you.
Edit: sorry. typed this wrong, first time, should be right nowI recommend you read this first... {: identifier of the thread = 886365}
and then you'll have a better idea of how to make to create a table in your query.
-
How to clear the history of cats?
Hello
How to clear the history of cats for each new session?
Thank you
Pascale
Hello Claudia,.
Can you please check if the user that you are trying to connect with is a "presenter or host? If the user is not presenter or host, and is just a participant user won't be able to clear the history of cats. And in this case, you will most likely the error you get. Please try to give such a user the role 'Presenter' or ' home' then try again and see if it works.
Let us know if this helped.
Thank you
Avinash
-
Return of the ref cursor of procedure where the cursor is defined in the specification
Hello
Here's pseudo-code
create or replace package test
as
cursor c_emp (number cv_emp_id)
is
Select emp_name emp where emp_id = cv_emp_id;
type ref_c is ref cursor;
function get_emp_name (number p_emp_id) return ref_c;
end test;
/
create or replace the test physics package
as
ref_c function get_emp_name (number p_emp_id)
is
ret_val ref_c;
Start
Open c_emp (p_emp_id);
ret_val: = c_emp;
return ret_val;
end get_emp_name;
end test;
/
Returns me "PLS-00382: expression is of the wrong type. I tried to use a strongly typed Ref cursor based on the cursor, but nothing helped.
Clearly, I understand something... and if I can't assign as ' ret_val: = c_emp "and if there is another key way it so please let me know.
Thank you
Ralph
Published by: user13024707 on May 5, 2010 04:43user13024707 wrote:
Clearly the point of my question is being missed.Or maybe the question is not been clearly asked. ;)
I want to set the cursor in the PACKAGE SPECIFICATION, and not in the package body. The issue of the bind variable and the string is neither here nor there because I pass parameters to the cursor.
What you ask is to use a PL/SQL cursor (defined in the specifications of the package or elsewhere) and that convert a Ref Cursor. N ° cannot be done.
PL/SQL cursors should be used in the PL/SQL code. REF CURSOR is primary used to pass back a reference to a cursor (and all queries are cursors) to a layer of application outside of PL/SQL for example .net, java, etc.. Once you start using the ref Cursor only really, you have the choice of opening it based on a (dynamic) or a fixed query string as in the examples given. You cannot open a cursor of a PL/SQL cursor definition Ref.The difference is that when you do:
CURSOR cur_mycursor IS SELECT ...
you declare a cursor in pl/sql definition, not actually a slider itself. The cursor itself is created when you issue an OPENING or a statement FOR etc. So a Ref Cursor (reference to a slider) cannot refer to the definition of the cursor because it is only a definition, not a cursor (i.e. it has not been sent engine sql and instantiated at that time here). Instead the Ref Cursor must reference a cursor (query), itself, and that may be presented as a string or as the query itself that is issued against the sql engine and then the ref cursor points
Thus, slider ref and PL/SQL cursors are different concepts, both designed to manage cursors in a slightly different way of programming. You cannot mix them.
-
How to clear the cache of firefox
How to clear the cache of firefox
Settings-Advanced below 'Network' and clear here
-
How to clear the history?
How to clear the history?
https://support.Mozilla.org/en-us/KB/how-do-i-clear-private-data-Firefox-Android
-
Portege Z930 - how to clear the memory of the fingerprint sensor?
Hello
Tell me how to clear the memory of the fingerprint sensor?
Reinstall the operating system and now I can not add your impressions.They have their No....
> Reinstall the operating system and now I can not add your impressions.
Stand by. You have reinstalled OS using original recovery image? -
Re: How to clear the model of Toshiba satellite PS271L - 6K 906 CMOS PASSWORD?
In: Toshiba
How to clear the model Toshiba Satellite PS271L - 6K 906 CMOS PASSWORD?
Please respond to my E-mail [email protected]
Thank youTo: King
http://forums.computers.Toshiba-Europe.com/forums/thread.jspa?MessageID=127837
Read this thread very carefully!
Maybe you are looking for
-
You can display the spotlight search history?
Is it possible to see what projector has sought on a certain date? I know how to view the history of Safari, but I was wondering if there was a way to see what Spotlight had sought on a certain date - I think that someone was on my computer one day,
-
Satellite P300 PSPCCE - Windows 7 drivers for touchpad
Hello I recently did a clean install of Windows 7 (on Vista, entered with my laptop). Everything works fine, but one thing annoys me a bit - with Vista, I could use the top/right edges of the touchpad to scroll down/on in windows & documents. On Wind
-
Fuzzy camera image-update?
I can't get the camera to focus well any resolution or "scene" I select. I cleaned the lens of the camera with a spray of cleaning for glasses and still no joy. That is what I'm missing that will get back my phone camera, focusing properly and Get sh
-
I change the window of my laptop HP 635 to Windows 7 ultimate and can not find drivers drivers
I change the window of my laptop HP 635 for window 7 ultimate and impossible to find some drivers. The drivers are listed below with their hardware ID Ethernet ControllerPCI\VEN_10EC & DEV_8136 & SUBSYS_3577103C & REV_05PCI\VEN_10EC & DEV_8136 & SUBS
-
Recently, I loaded my files on my rocket using the drag-and - déposer. I got my music organized into folders by type with just a layer of files under that. My music seems to be most of the time or what it but the "rocket" put the songs in different