using refcursor
What exactly is the use of the Ref Cursor?they affect performance?
Thks
810345 wrote:
NOW he will also perform the same function as my refcursor played and I think I can also use it in my front end and if yes, then which specializes in the ref cursor which forces me to think that I can do this thing in a different way, so I have to use ref cursor
What front end you intend to use?
If you use .NET, Java etc. then you will need to use a ref Cursor to move the pointer to the request to the front end, so that it (the front-end server) can retrieve records through this slider and close when you are finished. If you retrieve records with any other cursor in the PL/SQL code, then you will have to gather up of all data in a kind of structure of table/collection before moving all that data to the front-end server. If you do this, it will consume a lot of memory on the Oracle server and then involve passing ALL that data to the front end, while the front-end server can only needed to pick up the first recordings of a few.
REF CURSOR is the way to a 3rd party front-end to query the Oracle database. PL/SQL code, copy the following code already resides on the oracle database, and it can communicate directly with the database by using one of the other methods of the cursor.
Tags: Database
Similar Questions
-
Disadvantages of using REFCURSORs of JDBC
Hello
Normally, I write my SQL inside Java (for example PreparedStatements) statements.
I am studying on the establishment of the PL/SQL Packages, providing the procedures and methods, I can call Java using CallableStatements. I understand the benefits of having a layer/API on the database side.
For example: extract some records in a table. (the PL/SQL function getCustomers returns a REFCURSOR)
-PreparedStatement (select... from... where...)->-> loop ResultSet executeQuery
-CallableStatement ("start?: = getCustomers();") end; ")-> cast getObject() to ResultSet-> loop ResultSet
---
What are the disadvantages of using the CallableStatement (REFCURSOR)?
Thank you, best regards, Stephan>
I was thinking about the extraction of the differences of lines (line single OR multiple rows per round trip to the DB).If I understand correctly, I can set the size of Fetch on a CallableStatement (Oracle), so to get several lines of the REFCURSOR per round trip ticket to the DB.
>
Recovery of data from an Oracle database using cursors: no exceptions.The JDBC layer is what includes the "batch processing" feature that you describe and the feature is independent of the source of the cursor. If you use Oracle extensions, so you can take advantage of automated dosing of Oracle.
Using a REF CURSOR is how preferred and recommended to provide data from the database to an external client.
1. it minimizes dependencies between the DB and the customer. The function/procedure that provides REF CURSOR is the only dependency.
2. it maximizes the security of the data. Responsibility to secure data is based only on the side DB through the function/procedure. It is simply not possible for the Client software to access the data not authorized unless the function/procedure he has. The customer has NO access to the data, except by the REF CURSOR.
3. it maximizes the security of the database. Access to the database itself is easier to control. Customers only need to access an account that has extremely limited privileges: privilege to EXECUTE the function/procedure. Customers should not any table, view, or other privileges to do their job.
4. it minimizes the probability of error by the customer. It is impossible for the client to access the bad table/view or data. Customers don't need to know how to join tables or even know what are the name of the table or where the data resides.
5. it minimizes the knowledge and skills that the client developer needs to do their work. The client developer can focus on their two main issues: 1) what data do I need for my application, 2) what do I do with this data.
6. the risk of 'performance' (or sentence) is if the procedure/function is misspelled or uses wrong written queries to get the data.
In short use a REF CURSOR allows the developer to DB deal with the best way to provide the data and the developer client side withj records how to consume these data.
Use of any solution other than a REF CURSOR should be the EXCEPTION rather than the rule.
-
How to use refcursor type returned from the remote database in the local database
Can anyone say is how they use the refcursor use type returned from remote database in the local database using dblinks.See MOS ID 750126.1 doc ORA-24338 when trying to return a Refcursor over a database link.
-
Auto filling the fields using refcursor procedure
Dear all,
I have obligation where user enters the order number and press on enter or tab other fields must fill up automatically. I wrote the procedure to set its record returns. I want to call out of the procedure.
How can I do this?
Thanks in advancePlease read this article using Ref cursors to return recordsets and follow the example of code to retrieve the record in variables (elements of APEX page in your case)
You must write something like below
LOOP FETCH l_cursor //make sure you place the items in same order as your recordset columns INTO :P1_CUSTOMER_NAME, :P1_ORDER_DATE, :P1_DELIVERY_ADDRESS; EXIT WHEN l_cursor%NOTFOUND; END LOOP; CLOSE l_cursor;
Thank you
Vikram -
Hello
I went for a package listing
When I run the select statement in a SQL PLUS, it gives the result.
But when I try to use the same sql P_out_member OPEN for statement statement I'm unable to compile the package. I'm getting
PLS-00103 found 'string', but expected one of the following values: 'chain' "}, error"
Help, please.
Open P_out_member for SELECT x.memberid, x.alt_id, x.memfirstname, x.memlastname, x.meminitial, x.dob_dte, x.sex, x.street, x.city, x.state, x.zip, x.phone_number, x.LOB, x.elig_dte, NVL ((SELECT 'Y' FROM www_phr_extension phr WHERE phr.ghi_prov_num = '000000082295' AND phr.cert_no = x.hmo_certno AND phr.rec_code = x.rec_code AND ROWNUM = 1), 'N' ) phr_ind FROM (SELECT DISTINCT m.alt_id || '0' || SUBSTR (m.rec_code, -1, 1) AS memberid, m.alt_id, m.hmo_certno, m.rec_code, m.pat_firstname AS memfirstname, m.pat_lastname AS memlastname, m.pat_mi AS meminitial, TO_CHAR (TO_DATE (m.mem_dob, 'yyyymmdd'), 'mm/dd/yyyy' ) AS dob_dte, DECODE (SUBSTR (r.description, -4, 4), 'male', 'F', 'Male', 'M', 'N/A' ) AS sex, DECODE (a.street1, '', 'N/A', a.street1 || ' ' || a.street2 ) AS street, DECODE (a.city, '', ' ', a.city) AS city, DECODE (a.state, '', ' ', a.state) AS state, DECODE (a.zip_code, '', ' ', a.zip_code) AS zip, DECODE (SIGN (ASCII (g.comm_nmbr) - 57), 1, 'N/A', '', 'N/A', g.comm_nmbr ) AS phone_number, 'GHI HMO' AS LOB, TO_CHAR (TO_DATE (m.eff_date, 'yyyymmdd'), 'mm/dd/yyyy' ) AS elig_dte FROM mv_hmo_med_subscriber m, gos_subscriber_pcp c, subscriber_relation r, med_address a, (SELECT gs.cert_no, gs.rec_code, gs.comm_type, gs.comm_nmbr FROM gos_subscriber_comm gs WHERE gs.comm_type = 'HP') g WHERE m.hmo_certno = c.cert_no AND m.term_date = '00000000' AND m.rec_code = c.rec_code AND m.rel_code = r.rel_code(+) AND m.cert_no = a.cert_no(+) AND m.rec_code = a.rec_code(+) AND m.cert_no = g.cert_no(+) AND m.rec_code = g.rec_code(+) AND c.ghi_prov_num = '000000082295' AND ( (p_in_member_id IS NULL OR p_in_member_id = '' ) OR ( m.alt_id = p_member_id AND m.rec_code = p_rec_code ) ) AND ( ( p_in_member_last_name IS NULL OR p_in_member_last_name = '' ) OR m.pat_lastname = p_in_member_last_name )) x ORDER BY x.memlastname
You can try below
Open P_out_member for SELECT x.memberid, x.alt_id, x.memfirstname, x.memlastname, x.meminitial, x.dob_dte, x.gender, x.street, x.city, x.state, x.zip, x.phone_number, x.lob, x.elig_dte, NVL (y.phr_ind, 'N') phr_ind FROM (SELECT DISTINCT m.alt_id || '0' || SUBSTR (m.rec_code, -1, 1) AS memberid, m.alt_id, m.hmo_certno, m.rec_code, m.pat_firstname AS memfirstname, m.pat_lastname AS memlastname, m.pat_mi AS meminitial, TO_CHAR (TO_DATE (m.mem_dob, 'yyyymmdd'), 'mm/dd/yyyy') AS dob_dte, DECODE (SUBSTR (r.description, -4, 4), 'male', 'F', 'Male', 'M', 'N/A' ) AS gender, DECODE (a.street1, '', 'N/A', a.street1 || ' ' || a.street2 ) AS street, DECODE (a.city, '', ' ', a.city) AS city, DECODE (a.state, '', ' ', a.state) AS state, DECODE (a.zip_code, '', ' ', a.zip_code) AS zip, DECODE (SIGN (ASCII (g.comm_nmbr) - 57), 1, 'N/A', '', 'N/A', g.comm_nmbr ) AS phone_number, 'GHI HMO' AS lob, TO_CHAR (TO_DATE (m.eff_date, 'yyyymmdd'), 'mm/dd/yyyy') AS elig_dte FROM mv_hmo_med_subscriber m, gos_subscriber_pcp c, subscriber_relation r, med_address a, (SELECT gs.cert_no, gs.rec_code, gs.comm_type, gs.comm_nmbr FROM gos_subscriber_comm gs WHERE gs.comm_type = 'HP') g WHERE m.hmo_certno = c.cert_no AND m.term_date = '00000000' AND m.rec_code = c.rec_code AND m.rel_code = r.rel_code(+) AND m.cert_no = a.cert_no(+) AND m.rec_code = a.rec_code(+) AND m.cert_no = g.cert_no(+) AND m.rec_code = g.rec_code(+) AND c.ghi_prov_num = '000000082295' AND ( (p_in_member_id IS NULL OR p_in_member_id = '') OR (m.alt_id = p_member_id AND m.rec_code = p_rec_code)) AND ( (p_in_member_last_name IS NULL OR p_in_member_last_name = '') OR m.pat_lastname = p_in_member_last_name)) x LEFT OUTER JOIN (SELECT DISTINCT phr.cert_no, phr.rec_code, 'Y' phr_ind FROM www_phr_extension phr WHERE phr.ghi_prov_num = '000000082295') y ON y.cert_no = x.hmo_certno AND y.rec_code = x.rec_code ORDER BY x.memlastname
I think THAT this could be a problem
NVL ((SELECT 'Y' FROM www_phr_extension phr WHERE phr.ghi_prov_num = '000000082295' AND phr.cert_no = x.hmo_certno AND phr.rec_code = x.rec_code AND ROWNUM = 1), 'N' ) phr_ind
-
Hello
pls help me with the below error
Kind regardsCREATE OR REPLACE PROCEDURE PRM_SP_R_EMPLOYEE_LIST(o_emp_list OUT SYS_REFCURSOR) AS BEGIN prm_sp_oc_list('1,2'); open o_emp_list for Select PGLO_ORGN_CHART_CODE, PGLO_DESCRIPTION From PRM_C_Orgn_Chart ,prm_g_list_oc Where PGLO_PARENT_CODE=pcoc_orgn_chart_code and PCOC_ETDS_AT = 'Y' union Select Distinct pglo_orgn_chart_code, pglo_description From PRM_C_Orgn_Chart,PRM_G_LIST_OC Where PGLO_PARENT_CODE=pcoc_orgn_chart_code and PCOC_ETDS_At = 'Y' connect by prior pglo_parent_code = pcoc_orgn_chart_code Start With PCOC_Orgn_Chart_Code In (Select PGLO_Orgn_Chart_Code From PRM_G_LIST_OC,PRM_C_ORGN_CHART Where PGLO_PARENT_CODE=pcoc_orgn_chart_code and PCOC_ETDS_At = 'A'); for i in o_emp_list loop insert into prm_g_list_attibutes(PGLA_ATTRIBUTE_CODE,PGLA_ATTRIBUTE_VALUE,PGLA_DESCRIPTION) values(1,i.PGLO_ORGN_CHART_CODE,i.PGLO_DESCRIPTION); EXIT WHEN o_emp_list%NOTFOUND; END LOOP; END PRM_SP_R_EMPLOYEE_LIST; Error(16,11): PLS-00221: 'O_EMP_LIST' is not a procedure or is undefined
You have quite a slider Ref here. You may just have an implicit cursor to solve.
create or replace procedure prm_sp_r_employee_list(o_emp_list out sys_refcursor) as begin prm_sp_oc_list('1,2'); open o_emp_list for select pglo_orgn_chart_code, pglo_description from prm_c_orgn_chart, prm_g_list_oc where pglo_parent_code=pcoc_orgn_chart_code and pcoc_etds_at = 'y' union select distinct pglo_orgn_chart_code, pglo_description from prm_c_orgn_chart, prm_g_list_oc where pglo_parent_code = pcoc_orgn_chart_code and pcoc_etds_at = 'y' connect by prior pglo_parent_code = pcoc_orgn_chart_code start with pcoc_orgn_chart_code in (select pglo_orgn_chart_code from prm_g_list_oc,prm_c_orgn_chart where pglo_parent_code=pcoc_orgn_chart_code and pcoc_etds_at = 'a'); for i in (select pglo_orgn_chart_code, pglo_description from prm_c_orgn_chart, prm_g_list_oc where pglo_parent_code=pcoc_orgn_chart_code and pcoc_etds_at = 'y' union select distinct pglo_orgn_chart_code, pglo_description from prm_c_orgn_chart, prm_g_list_oc where pglo_parent_code = pcoc_orgn_chart_code and pcoc_etds_at = 'y' connect by prior pglo_parent_code = pcoc_orgn_chart_code start with pcoc_orgn_chart_code in (select pglo_orgn_chart_code from prm_g_list_oc,prm_c_orgn_chart where pglo_parent_code=pcoc_orgn_chart_code and pcoc_etds_at = 'a')) loop insert into prm_g_list_attibutes ( pgla_attribute_code, pgla_attribute_value, pgla_description ) values ( 1, i.pglo_orgn_chart_code, i.pglo_description ); end loop; end prm_sp_r_employee_list;
If you do not want the output parameter, then you can remove the ref cursor in the procedure.
Note: That's what william meant by ;) formatted code
Thank you
Knani. -
Hi guys,.
I stumbled upon this procedure using refcursor inside a loop, as below. My understanding is that the person wrote the code thinking it will add the data in the cursor.
create or replace PROCEDURE (proc_test)
RC1 ON SYS_REFCURSOR)
cursor CSR is separate select deptno from emp;
Start
for rec loop of CSR
Open rc1 for "select * from Department where deptno = ' |" Rec.DEPTNO;
-make your...
end loop;
close the CSR;
end;
/
I have it except to error with cursor already open, instead, I got a few results im not able to correlate.
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
"CORE 11.2.0.3.0 Production."
AMT for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
As usual, it helps to RTFM. Opening and closing of cursor Variables:
You must not close a cursor variable before reopening it (i.e. use it in another
OPEN
FOR
instruction). After having reopened a cursor variable, the previously associated query there is lost.SY.
-
Insert the output of a refcursor procedure into a table
Hello
I met a scenario in which I need to put the insert records returned by a procedure using refcursor, at a table.
I followed the instructions in PL/SQL 101: understanding Refcursor (PL/SQL 101: understanding Ref Cursor am unfortunately still not able to do so.)
Here is my sample codes. (Copied here as advised by the new Member)
I check the result using the following statement, which gives results.create or replace PROCEDURE TEST_PROCEDURE1 ( p_cursor OUT SYS_REFCURSOR) AS BEGIN OPEN p_cursor FOR SELECT C1,C2 FROM TEST_USER.test_table4procedure; END;
Now, I want to be able to use the output and insert the data into a table. That's how I came across this thread.variable rc refcursor; exec TEST_USER.TEST_PROCEDURE1 (:rc) print rc;
I created the types and function...
After that, I want to be able to view the records by using the function... so I used the instructions below...create or replace type test_user.type_table1 as object(var1 varchar2(50),var2 varchar2(50)); create or replace type test_user.type_table2 as table of test_user.type_table1; create or replace function test_user.test_function1 (rc in sys_refcursor ) return test_user.type_table2 is v_emptype test_user.type_table2 := test_user.type_table2(); -- Declare a local table structure and initialize it v_cnt number := 0; v_rc sys_refcursor; v_var1 varchar2(20); v_var2 varchar2(20); begin v_rc := rc; loop fetch v_rc into v_var1, v_var2; exit when v_rc%NOTFOUND; v_emptype.extend; v_cnt := v_cnt + 1; v_emptype(v_cnt) := test_user.type_table1(v_var1, v_var2); end loop; close v_rc; return v_emptype; end;
However, it fails with the errorvariable rc refcursor; exec TEST_USER.TEST_PROCEDURE1 (:rc) SELECT * FROM TABLE(test_user.test_function1(:rc));
Error from line 3 in order:
SELECT * FROM TABLE (test_user.test_function1 (:rc))
Error report:
SQL error: Missing a setting IN or OUT to index: 1
Help, please...Your code does not work for a simple reason. SYS_REFCURSOR parameters must be in IN OUT mode. Check if the RC is open when he switched mode:
create or replace type type_table1 as object(var1 varchar2(50),var2 varchar2(50)) / create or replace type type_table2 as table of type_table1 / create or replace PROCEDURE TEST_PROCEDURE1 (p_cursor IN OUT SYS_REFCURSOR) AS BEGIN OPEN p_cursor FOR SELECT ENAME,JOB FROM EMP; END; / create or replace function test_function1 (rc in sys_refcursor ) return type_table2 is v_emptype type_table2 := type_table2(); -- Declare a local table structure and initialize it v_cnt number := 0; v_var1 varchar2(20); v_var2 varchar2(20); begin if rc%isopen then dbms_output.put_line('rc is open'); else dbms_output.put_line('rc is not open'); end if; loop fetch rc into v_var1, v_var2; exit when rc%NOTFOUND; v_emptype.extend; v_cnt := v_cnt + 1; v_emptype(v_cnt) := type_table1(v_var1, v_var2); end loop; close rc; return v_emptype; end; / variable rc refcursor exec TEST_PROCEDURE1(:rc) set serveroutput on SELECT * FROM TABLE(test_function1(:rc)) / SELECT * FROM TABLE(test_function1(:rc)) * ERROR at line 1: ORA-01001: invalid cursor ORA-06512: at "SCOTT.TEST_FUNCTION1", line 15 rc is not open SQL>
Now IN OUT parameter edit mode:
set serveroutput off create or replace function test_function1 (rc in out sys_refcursor ) return type_table2 is v_emptype type_table2 := type_table2(); -- Declare a local table structure and initialize it v_cnt number := 0; v_var1 varchar2(20); v_var2 varchar2(20); begin if rc%isopen then dbms_output.put_line('rc is open'); else dbms_output.put_line('rc is not open'); end if; loop fetch rc into v_var1, v_var2; exit when rc%NOTFOUND; v_emptype.extend; v_cnt := v_cnt + 1; v_emptype(v_cnt) := type_table1(v_var1, v_var2); end loop; close rc; return v_emptype; end; / variable rc refcursor exec TEST_PROCEDURE1(:rc) set serveroutput on declare v_emptype type_table2 := type_table2(); begin v_emptype := test_function1(:rc); end; / rc is open PL/SQL procedure successfully completed. SQL>
Problem is that you can't call the procedure/function with parameters in/out OUT of SQL.
SY.
-
Hello
Can I use REFCURSOR in the package.
If not why?Yes...
see the example.CREATE OR REPLACE PACKAGE CURSPKG AS TYPE T_CURSOR IS REF CURSOR; PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, IO_CURSOR IN OUT T_CURSOR); PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, DEPTCURSOR OUT T_CURSOR); END CURSPKG; CREATE OR REPLACE PACKAGE BODY CURSPKG AS PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, IO_CURSOR IN OUT T_CURSOR) IS V_CURSOR T_CURSOR; BEGIN IF N_EMPNO <> 0 THEN OPEN V_CURSOR FOR SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO AND EMP.EMPNO = N_EMPNO; ELSE OPEN V_CURSOR FOR SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO; END IF; IO_CURSOR := V_CURSOR; END OPEN_ONE_CURSOR; PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, DEPTCURSOR OUT T_CURSOR) IS V_CURSOR1 T_CURSOR; V_CURSOR2 T_CURSOR; BEGIN OPEN V_CURSOR1 FOR SELECT * FROM EMP; OPEN V_CURSOR2 FOR SELECT * FROM DEPT; EMPCURSOR := V_CURSOR1; DEPTCURSOR := V_CURSOR2; END OPEN_TWO_CURSORS; END CURSPKG;
Mezaber
-
Refcursor takes a long time to print the results
Hi gurus,
I have a table with name kemp with columns
kemp_ID NOT NULL NUMBER (10)
when I do a query on the table
ACRONYM CLOB
TERM CLOB
DEFINITION of CLOB
Select * Kemp; results will soon appear less than * 1.5 seconds *
But when I write a procedure to return the results using refcursor
Create procedure pr_retall (cv_1 in the sys_refcursor)
as
Start
Open SELECT cv_1 * Kemp;
end;set serveroutput size unlimited;
It takes around * seconds * 7 to appears.
var x 1 refcursor;
exec pr_retall(:x1);
print x 1;
Please tell me know ways to tune. I want to reduce the time that it is to consume.
Thank you and best regards,
Vikas KrishnaVikas Krishna wrote:
Please find the schedule.
Using elapsed time (like you) to measure and benchmark performance is not going.
Why? Because the test2 is given rarely, if ever how these tests are usually done, executed with the help of the same conditions that test1 was executed in.
Conditions are different between the tests, the elapsed time is different. As conditions differ, you cannot compare test1 with test2. I gave an example of what a mistake it is thread {message identifier: = 4333700}-where physical i/o slows test1 and test2accelerates the logic I/O. And how this can be used to support the conclusion that the CBO does not exist hint warp_drive increased performance of test2.
If you want to compare test1 against test2, you must know exactly in detail how each test works technically... you want to know how to ensure that the common point between two tests remain constant for all tests and how to measure only the elements that differ between tests.
And no, the comparative analysis is not that complex. In fact, it is even more complex than that. It is best left to those who know how to compare... on behalf of those who can find significance in the result of this benchmark.
For the majority of us work and development in the real world, comparative analysis makes a useless answer to a question meaningless for an absurd question. Totally useless...
-
I have a function that returns a refcursor based on two dates.
Here I'm unable to print the refcursor records. Please help me.
This is my sample code:
DECLARE
RetVal TYPES. REF_CURSOR;
DATE OF V_DATE_1;
DATE OF V_DATE_2;
BEGIN
"V_DATE_1: = July 20, 2008;
"V_DATE_2: = July 13, 2008;
RetVal: = GET_PSTPS_BY_MULT_DATES_SP (V_DATE_1, V_DATE_2);
for i in 1.RetVal.count
loop
DBMS_OUTPUT. Put_line (' cursor values are: ' |) RetVal.i);
end loop;
COMMIT;
END;
/
Thanks in advance
RambeauHere's an example of how you can use refcursor:
SQL> DECLARE 2 RetVal sys_refcursor; 3 l_val dual%rowtype; 4 5 BEGIN 6 7 open RetVal for select * from dual; 8 9 10 loop 11 fetch RetVal into l_val; 12 exit when RetVal%notfound; 13 dbms_output.put_line(l_val.dummy); 14 end loop; 15 16 END; 17 / X PL/SQL procedure successfully completed SQL>
7. open RetVal to select * twice; -do the same things as RetVal: = GET_PSTPS_BY_MULT_DATES_SP (V_DATE_1, V_DATE_2);
-
Any chance to rewrite this code?
Can this code be rewritten more efficiently?
Oracle version: 10.2
Published by: BlueSkies July 18, 2012 06:03PROC_CODE SYS_REFCURSOR; IF (OBJ_NAME = 'PROC' OR OBJ_NAME = 'MAT1') AND RGN_CODE = 'EU' THEN OPEN PROC_CODE FOR SELECT PROC_EXT_UNIQ_ID, PROC_ASSIGNED_TO, PROC_OWNER_EXT_UNIQ_ID, PROC_CUST_EXT_UNIQ_ID FROM TRACK_BIU_PROC WHERE PROC_COUNTRY_CODE = RGN_CODE AND SKIP_FLAG = 'A' LOOP FETCH PROC_CODE INTO PROC_UNIQ_ID, PROC_ASSIGNED_TO, PROC_OWNER_ID, PROC_CUSTOMER_ID; EXIT WHEN PROC_CODE%NOTFOUND; IF PROC_ASSIGNED_TO IS NULL AND PROC_OWNER_ID IS NULL THEN BEGIN SELECT MANH_MGR INTO ASH_WM_CD FROM HEW_RAM_MASTER WHERE MANH_NO = PROC_CUSTOMER_ID AND FETCH_CODE = p_ftcode; EXCEPTION WHEN NO_DATA_FOUND THEN ASH_WM_CD := '+'; END;
Use SQL Direct does not use REFCURSOR. Your two SQL can be combined like this.
select t.proc_ext_uniq_id, t.proc_assigned_to, t.proc_owner_ext_uniq_id, t.proc_cust_ext_uniq_id, nvl(h.manh_mgr, '+') manh_mgr from track_biu_proc t left join hew_ram_master h on h.manh_no = t.proc_customer_id and h.fetch_code = p_ftcode where t.proc_country_code = rgn_code and t.skip_flag = 'A'
-
2 refcursors within the same procedure using
Hello
Can we use 2 refcursors within the same procedure. This may seem strange. But I have a script to do so - one to dynamically check for some validations and another to return a result set.Yes, pass by the example below.
CREATE OR REPLACE PACKAGE CURSPKG AS
TYPE T_CURSOR IS REF CURSOR;
PROCEDURE (EMPCURSOR ON T_CURSOR OPEN_TWO_CURSORS,
DEPTCURSOR ON T_CURSOR);
END CURSPKG;
/
CREATE OR REPLACE PACKAGE BODY CURSPKG AS
PROCEDURE (EMPCURSOR ON T_CURSOR OPEN_TWO_CURSORS,
DEPTCURSOR ON T_CURSOR)
IS
V_CURSOR1 T_CURSOR;
V_CURSOR2 T_CURSOR;
BEGIN
V_CURSOR1 OPEN FOR SELECT * FROM EMP;
V_CURSOR2 OPEN FOR SELECT * FROM THE DEPARTMENT;
EMPCURSOR: = V_CURSOR1;
DEPTCURSOR: = V_CURSOR2;
END OPEN_TWO_CURSORS;
END CURSPKG;
/I hope that it would be useful.
-
Call a procedure that returns a refcursor, use it in an another proc sql?
I have a procedure that returns a refcursor; How can I include this refcursor in a sql statement that is inside another procedure, or view etc.?
This is the kind of foolery, I tried so far (myproc1 returns a ref cursor):
create or replace procedure myproc2
(
slider ref RC
)
AS
RC1 of ref cursor;
Start
EXECUTE myproc1 (rc1).
Open rc for
Select rc1.* in the rc1;
end myproc2;If you want to use the result set in an SQL Ref Cursor won't be of any help. Can be read all nested Table Type. You can declare an object type and store your result in them and use them in SQL.
Thank you
Knani. -
Should I use OracleCallableStatement to treat a REFCURSOR?
Oracle 10g 2 Rel using last Oracle thin driver on a Java 1.5 application.
I'm porting of our existing application to Oracle, but for the next few months, I do need to support several databases (SQL Server, DB2) with the same line of code. Our db access layer is stored procs wrapped in CallableStatements according to which a large majority returns a set of results. I so need to continue to use the ResultSet objects and existing java.sql.CallableStatements.
A typical stored proc looks like this:
CREATE OR REPLACE PROCEDURE getMeData
(
v_c_columnname IN VARCHAR2 DEFAULT NULL,
v_intSort IN the DEFAULT NUMBER 0.
cv_1 IN OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN FOR Cv_1
SELECT col1,
col2,
COL3
FROM someTable
WHERE somecolumn = v_c_columnname;
END;
/
We have summarized currently calls stored procedure by doing a check on which db platform, then wrapping with either EXEC or dial the CALL and the construction of the proc for the target RDBMS.
My first question is: is it possible for me to handle/process the REFCURSOR back in java.sql.Callable vanilla games/statement of results, or if I have to use oracle.jdbc.CallableStatment (and save the output cursor type (IE, cStmt.registerOutParameter (3, OracleTypes.CURSOR)?))
Second question - I'm currently testing with the OracleCallableStatement, but my cStmt.execute will simply ignore the call of execute - I know its built correctly, and when I call via pl/sql with the dregs, it returns correctly, so am I missing something in the way of treating the REFCURSOR? It is not fails with an Oracle error, it's just not executing.
It's the call:
begin getMeData(?,?,?); end;
Last question - must use a REFCURSOR to return a result set via PL/SQL stored procs, or is there another way?
TIAright. She must be from an Oracle driver to work
with JDBC Oracle oracle-specific characteristic examples.
Maybe you are looking for
-
Hello I have a MacBook Pro that, if I'm not mistaken that I bought in 2009. So, last week I had several open files and I was typing on a Word document, I typed whenever he got more lag. Then my laptop just turned off automatically and I received a me
-
context menu at the end of the song titles
There is an automatic button appearing which is positioned directly after the name of the piece of any song that I pass my mouse over when itunes is in list mode. The appearance of the button is a circle with 3 dots inside the circle. The button is p
-
To clean my Mac I should Clean 3 MYMAC announcing it clears redundant material.
-
Problem of FaceTime with a specific person
I'm not FaceTime with my friend who is Dubai? But he could do FaceTime with other people? I have not tried with different people in Dubai
-
How can I view an encrypted file locked with a password
I have a network shared with my husband and it some of my files encrypted and some need a password for access to via WinLocker. How can I view them? Can I find a free program of decryption or something since I am the owner of this computer and have