ResultSet sys_refcursor
Hi Master,
I created a function that will return the result set of the emp table. I must use this result set in another procedure/function. Is this possible?
I have writtne a feature like this...
create or replace function test (v_sal in number) return is sys_refcursor
v_cur sys_refcursor;
Start
Open v_cur SELECT * from emp where sal > = v_sal;
Return v_cur;
end;
SQL > select test (2000) twice;
6 rows displayed.
I need to use this record to filter another subprogramme? is this possible? Please advise... !!!
Concerning
AP
PL/SQL 101: Understand the Ref Cursor
Tags: Database
Similar Questions
-
helps the sys_refcursor
I created my procedure like this
CREATE OR REPLACE
PROCEDURE PROCEDURE1
(resultSet ON sys_REFCURSOR
) AS
BEGIN
Open the result set for
Select tr.col1
of scm.training tr;
END PROCEDURE1;
When I try to compile
Error (7.4): PL/SQL: statement ignored
Error (8,13): PL/SQL: ORA-00942: table or view does not exist
I know that the table exists and have a permission for my schema
When I try to run this sql it gives the results
Select * from scm.training
Is there something happens with sys_refCursorNothing wrong with sys_refcursor - but something wrong with the permissions of your schema within the PL/SQL language, or with your scope-resolution.
What is your schema name?
What is the scm.training object and if your schema is not scm, how were select privs granted to your schema on scm.training object?
-
Insert into table primary key (automatic numbering) for back in class resultset
Hello
I connect to Oracle 10 g via JDBC (ojdbc14.jar is).
My SQL statement is:
INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test');
SELECT Student_studentId_SEQ. NEXTVAL FROM DUAL;
FYI - the Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.
The above will do (from the point of view of Java app) is to create a school record and automatically select the student card and student card is accessible via the resultset in Java.
I get the error message ' ORA-00911: invalid character '. Can you please help?
Kind regards
Jason
Published by: user10394130 on October 13, 2008 02:40As I said already try using a refcursor like that.
DECLARE
seqNbr_studentId NUMBER (12): = 0;
stud_cur SYS_REFCURSOR;
BEGIN
INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test')
StudentId INTO seqNbr_studentId RETURN;
Stud_cur OPEN to SELECT seqNbr_studentId OF MODEL;
END;Thank you
Knani. -
Hey Geeks,
I am trying to execute the procedure from the SQL Developer, but these errors are coming. What can I do wrong here...
Procedure works fine when I run the compilation and debugging mode. But I need to put later in the c# code.
SET serveroutput on;
DECLARE
OutParam1 to SYS_REFCURSOR;
OutParam2 ON Varchar;
BEGIN
/ * Call procedure package * /.
SPAT_QUERY. SP_VALIDATERULES (9, 'BIS2015001', OutParam1, OutParam2);
/ * Display parameters * /.
dbms_output.put_line ('OutParam1: ' |) OutParam2);
END;
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Error report-
ORA-06550: line 3, column 20:
PLS-00103: encountered the symbol "SYS_REFCURSOR" during the expected in the following way:
:= . (@ %; not null default range character)
06550 00000 - "line %s, column % s:\n%s".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Procedure below:
create or replace PACKAGE SPAT_QUERY of BODY
AS
/ * Declare a global variable to hold the result of the Validation. */
valResult varchar (10);
PROCEDURE SP_VALIDATERULES)
IN_RQST_NUM NUMBER,
IN_CASEID IN VARCHAR,
OUT_REFCURSOR ON SYS_REFCURSOR,
OUT_VAL_RSLT ON VARCHAR
)
AS
p_rc sys_refcursor;
I have NUMBER: = 0;
/ * Logical query - a loop in the Table of RULES based on request NUM * /.
BEGIN
FOR rec IN (SELECT * FROM T_RULES where RQST_NUM = IN_RQST_NUM)
LOOP
i: = i + 1;
SP_GETSECTS (IN_CASEID, rec. LYR_TX, rec. TRGT_TX, rec. EXCPTD_RSLT_CD, p_rc);
OUT_VAL_RSLT: = valResult;
END LOOP;
END SP_VALIDATERULES;
Thank you
Ken
in anonymous block, variables cannot be defined in the form. IN and OUR are not variable parameters type
Change your code to
DECLARE
OutParam1 SYS_REFCURSOR;
OutParam2 Varchar;
-
create or replace procedure p1 (one in sys_refcursor)
is
b emp.ename%type;
Start
loop
look for one in b;
exit when a % notfound;
dbms_output.put_line (b);
end loop;
end;
/
procedure is created but the execution:
Start
P1('SCOTT');
end;
/
ERROR on line 2:
ORA-06550: line 2, column 1:
PLS-00306: wrong number or types of arguments in the call to 'P1 '.
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
Note: Please help me how to run?
SQL> declare 2 rc sys_refcursor; 3 begin 4 open rc for select a from foo; 5 p1(rc); 6 end; 7 /
-
Problem of iteration ResultSet
Scenario is,
I have a ResultSet rs, contained some database data, once I visit any rs and display data from it, then call rs.beforeFirst (); to iterate again but this time it doesn't show any output, my code is below
try {} While (RS. Next()) { System.out.println ("Dash first" + rs.getString (1)); } } catch (SQLException ex) { }
Try { rs.beforeFirst (); While (RS. Next()) { System.out.println ("time 2nd iteration" + rs.getString (1)); } } catch (SQLException ex) { } This is according to the type of result set, default type is TYPE_FORWARD_ONLY cursors, it means that the cursor moves forward only in this case you cannot use rs.beforeFirst (); What you can do is to re - run once again the statement as:
rs = stat.executeQuery(); while (rs.next()) { System.out.println(rs.getString(1) + " - 1st time Iterating"); } System.out.println("------------------------------"); rs = stat.executeQuery(); while (rs.next()) { System.out.println(rs.getString(1) + " - 2nd time Iterating"); }
If you want the cursor result set can move forward and backward in the ResultSet Type TYPE_SCROLL_INSENSITIVE value and in this case, you can use rs.beforeFirst (); as:
conn = getConnection(); Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE , ResultSet.CONCUR_READ_ONLY); String sql = "select department_name from departments"; rs = stat.executeQuery(sql); while (rs.next()) { System.out.println(rs.getString(1) + " - 1st time Iterating"); } System.out.println("------------------------------"); rs.beforeFirst(); while (rs.next()) { System.out.println(rs.getString(1) + " - 2nd time Iterating"); }
-
How to access HDA to format resultset values in ServiceHandler or a filter
If I have a ResultSet MYSET defined in resources such as file
@ResultSet RIGHT
3
col1
col2
COL3
val11
val12
val13
val21
val22
val23
@end
How access in Java class and get the content?
Hello
This problem is solved with the line of code below:
RSet.First ();
and I am able to retrieve the values.
Thank you.
-
Hello
I have a ResultSet in Idoc Script that contains the reports in a given year. I have to loop through this result set to display all of them. They usually appear in groups (example: 3 for 1 Jan, 2015, 5 reports for Jan. 15, 2015, etc.).
What I would also like to get is the number of reports for a given date. In order to accomplish, I want to loop through the result set again whenever a new date is met.
Here's what I do now:
<!-$innerResultSet = "Search results"->
<!-$previousDate = ""--> ".
<! - $loop SearchResults - >
<!-$currentDate = formatDateWithPattern (release date, "MM/dd/yy")->
<!-not currentDate as previousDate $if->
<! - $reportCount = 0 - >
<!-$rsFirst (innerResultSet)->
<!-$loopwhile getValue (innerResultSet, "#isRowPresent") - >
<!-$if formatDateWithPattern (release date, "MM/dd/yy") as currentDate->
<! - $reportCount = reportCount + 1 - >
<!-$endif->
<!-$rsNext (innerResultSet)->
<!-$endloop->
...
<!-$endif->
...
<! - $previousDate = currentDate - >
<!-$endloop->
It seems that after the first iteration of the inner loop, that progress on the outer loop is lost (it only iterates on the outer loop).
Thank you very much in advance for any help. I hope that the above code allows, if I need to elaborate please let me know.
Thank you!Josh
You can... hope you follow the logic.
(create a resultset placeholder for records on the same day and display when the date is changed)
( documents)
( documents)
-
NOCOPY Hint in a SYS_REFCURSOR.
I hava a procedure with a parameter of output SYS_REFCURSOR and there is a warning that I can take advantage of a NOCOPY HINT.
Isn't the REF CURSOR already a reference? What would be the real advantage in terms of performance by adopting such a suggestion?
Thanks in advance.
It's the PLW-07203 warning that apears after a compilation in a session with:
ALTER SESSION SET PLSQL_WARNINGS = ' ENABLE: ALL ';
'Parameter 'chain' likely to benefit from the use of the NOCOPY compiler flag.
http://docs.Oracle.com/CD/B28359_01/server.111/b28278/plwus.htm#PLW-07203
Don't know, but it's probably just a warning of 'catch-all '.
REF CURSOR is pointers, so no matter how it happened, you can still have multiple pointers to the same location and risk having the problem of "aliasing" described in the doc:
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/subprograms.htm#CHDEBECB
Subprogramme parameter Aliasing with variable cursor parameters
Cursor variables are pointers. Therefore, if a subroutine assigns a parameter variable cursor to another, they refer to the same memory location. This folding can have unexpected results.
In the example 8-19, the procedure has two variable slider settings,
emp_cv1
andemp_cv2
. The procedure opensemp_cv1
and sets its value (which is a pointer) toemp_cv2
. Nowemp_cv1
andemp_cv2
refer to the same memory location. When the procedure endsemp_cv1
, it also closesemp_cv2
. Therefore, when the procedure is trying to get toemp_cv2
, PL/SQL raises an exception.Example 8-19 parameters sub-program Variable Cursor alias
A cursor is NOT given, so copying is not accomplish the type of separation that makes copy of data.
If you copy data, then you have TWO copies of the data. A change to each copy will NOT change the other copy.
As shown in example 8-19 in this doc copy that a cursor does not copy any data - it provides just TWO paths to it.
-
sys_refcursor function call
function execute_lov (in_lov_id NUMBER, in_opc_id, P_REF_CUR to SYS_REFCURSOR)
end;
How to call iam funtion todo as this error of setting train can u help me for this
Declare
v_rc sys_refcursor;
mycv1 sys_refcursor;
BEGIN
SELECT DTC_LC_WEB_PKG. EXECUTE_LOV (75,2345,v_rc) in the double mycv1;
dbms_output.put_line (' lines: ' | mycv1);
END;
Thank you
Olivier
is not necessary, I got solution
DECLARE
sys_refcursor v1;
VARCHAR2 (200) v2;
BEGIN
/ * Get ref cursor... * /.
V2: = DTC_LC_WEB_PKG. EXECUTE_LOV (75,5144,v1);
dbms_output.put_line ('refcursor' | v2);
END;
-
Hi all!
I am facing a very frustrating problem and not sure what to do next. I have re-implemented it anyway I know not how to reach them without success. I think this is an environmental issue but I'm not sure what to change, or where and web research has me around in circles; It is possible that I am doing something wrong to build my custom component that I know.
(Note: this is the right version UCM11g before they added support ADF. > sigh <)
Use cases for cause: the custom component works perfectly up to > 700 content items are in the workflow, and then it generates the error:
! csUserEventMessage,DONH,efilingd.lgbs.com:16200!csSystemCodeExecutionError!syJavaExceptionWrapper,java.lang.OutOfMemoryError: allocLargeObjectOrArray: [it\, size 67108880
(Note: Weblogic Server startup argumet is:-Xmx1024m))
The issue is consistent, but sometimes it allows you to get a little further, entering errors
Case 1: It loads when the user clicks on the link on the menu (all 925 lines), but then, when you try to click a link in the header (sorting), it will throw the error
Case 2: It will not load unless you click on the "My Workflow Assignments" link first, then click the custom menu WF
Summary of the element:
It is an attempt to 'copy' "My Workflow assignments" with some additional custom metadata added columns.
Essentially, I defined a custom Service "LIT_MYWORKFLOWS" (which I have added to the 'My Content Server"menu as a new link) who uses his custom template"LIT_WF_INQUEUE_LIST"(with overloaded includes) to present the complete column as well as a resource of query to retrieve the data in a result set called WorkflowInQueue
Relevant MyComponent. extracted:
query
Resources/lit_myworkflows_page_query.htm
Lit_MyWorkflows_Page_Queries
10
service
Resources/lit_myworkflows_page_service.htm
Lit_MyWorkflows_Page_Services
10
resources
Resources/lit_myworkflows_page_resource.htm
null
10
model
Resources/lit_myworkflows_page_template. HDA
null
10
Resource.htm relevant query
< Lit_MyWorkflows_Page_Queries @table @ >
...
QLitWorkflowInQueue < td > < table >
DM.xsuitnumber, dm.xsuitkey, dm.xvenue, dm.xcourtnumber, dm.xteam, dm.xdocumentstatus, dm.xdocumentstatusdate, dm.xdocdeadline, substr(dm.xefiledocument,0,1) xefiledocument, initcap (wq.dwfqueueactionstate) < td > SELECT "wfLastAction", wq.*
OF dm, workflowinqueue wq docmeta
WHERE dm.did = wq.did AND
Wq.duser =?
ORDER BY wq.dwfQueueLastActionTs DESC < table >
< td > < table > varchar dUser
(Note: the workflowinqueue table is from "Patch" link Oracle WfDbInQueue growing WF items in the DB (abandonment of user topic file storage))
Oracle component works very well and is not part of the question. I was getting this error even before that we installed when I used Java to 'capture' the WorkflowInQueue
ResultSet after "out of the box" algorithm the load in the file of the user topic, I was then adding my custom columns and data.
Now I can use a query Java simple versus complex, just as they are)
Relevant Service.htm
< td > LIT_MYWORKFLOWS < table >
< Td > WorkflowService
33
LIT_WF_INQUEUE_LIST
null
value Null < br >
value Null < table >
< td > 5:QLitWorkflowInQueue:WorkflowInQueue:0: cannot run QLitWorkflowInQueue < table >
(Note 1: the error if I use "WorkflowInQueue" as the name of class ResultSet or (with customization much more) use a completely different name LitWorkflowInQueue)
(Note 2: If you are not familiar with how to read this without the wizard, it is a query of type "Select query cache" with no set of masks of control)
Please let me know if any additional info could get more clarity.
Understand how to solve this problem would be greatly appreciated! Thanks in advance!
At first glance, 1024 m is a bit weak in terms of memory. 10g 3 and earlier versions, you * could * have been able to slip by with a concert, but WLS overload actually eat your available memory. A good starting point is usually 2 GB, and it's pretty easy to bump up the memory.
If it does not (which means that you get the same error regardless of 1 GB or 2 GB of memory), try the parameter "UseBufferPools = false" in the config.cfg and see if that gets past the question.
-
Hello
I have 3 tables with the following structure.
create table a_os_lang_stls
(ID NUMBER )
SWB_NUMBER VARCHAR2 (30),
Pc_NUMBER VARCHAR2 (30),
PC_FLAG TANK (1),
INSTALLATION_ord NUMBER ,
SP_OR_LATER_VSN TANK (1),
Platform VARCHAR2 (4000),
OS VARCHAR2 (4000),
LANG VARCHAR2 (4000),
LOSS_OF_FUNC_REASON_TXT VARCHAR2 (4000),
CREATION_DATE DATE ,
MODIFIED_DATE DATE ,
CREATED_BY VARCHAR2 (100 BYTE),
MODIFIED_BY VARCHAR2 (100 BYTE)
);
Insert in a_os_lang_stls
values (1 'SWB1' 'SWB0','P',1 of ','11118,14,16,234,124' '12,26,17,24,35''34,28,45,67,123,95',USER, NULL, NULL, NULL, SYSDATE);
Insert in a_os_lang_stls
values (2,'SWB1' 'SWB2','P',2 of ','111,20,14,16,124''11,26,18,24,35''35,27,42,67,123,95', SYSDATE, NULL, NULL, NULL, USER);
insert into a_os_lang_stls
values (3,'SWB1','SWB3','C', 1,'','11118,14,16,234,124','12,26,17,24,35',' 35,27,42,67,123,95', SYSDATE, NULL, NULL, NULL, USER);
insert into a_os_lang_stls
values (4,'SWB1','SWB4','C', 2,'','111,20,14,16,124','11,26,18,24,35'' 34,28,45,67,123,95, SYSDATE, NULL, NULL, NULL, USER)
CREATE TABLE os_dtls
(
OSCODE VARCHAR2 (10 BYTE),
ID NUMBER DEFAULT NULL,
AG_OSCODE VARCHAR2 (250 BYTE),
);
insert into os_dtls
values ('HUX', 12, 'HP UNIX');
insert into os_dtls
values('SUX',26,'SOLARIS');
insert into os_dtls
values ('LUX', 17, 'LINUX');
CREATE TABLE lang_dtls
(
LANGCD TANK (2 BYTE),
LANGNAME VARCHAR2 (255 BYTE),
ID NUMBER DEFAULT 1 NOT NULL
);
insert into lang_dtls
values ('ENG', 'ENGLISH UK', 35);
insert into lang_dtls
values ('UEG', 'USA ENGLISH', 27);
insert into lang_dtls
values('FR','FRENCH',45);
Information on the database:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
PL/SQL version 11.1.0.7.0 - Production
Production base 11.1.0.7.0
AMT for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
I have to write a procedure like this
procedure os_lang_info (P_SB_NO IN varchar2, p_pcur sys_refcursor, p_ccur, sys_refcursor );
The requirement is to get the details for a given swb_no where pc_flag is P or C pass like 2 different sys_refcursor. But the value of column of bones and lang I need to map to the os_dtls and lang_dtls tables to get the ag_oscode and langname respectively for the corresponding id then through sys_refcursor.
So sys_refcursor structure will be
Open the p_pcur for
Select * from a_os_lang_stls
where swb_number = p_sb_no
and PC_FLAG = 'P' ;
so the output will resemble the following
1 , « SWB1 » , « SWB0 » , 'P' , 1 , 'S' , '11118,14,16,234,124' , «HP UNIX,SOLARIS,LINUX,... « , "UK ENGLISH,US ENGLISH,FRENCH,...» ', NULL, NULL, NULL, USER, SYSDATE
I must get the id separated by commas of column bone and lang and map to the corresponding table to get the names separated by commas of the bones and langs and pass it as a component of sys_refcursor.
Open the p_ccur for
Select * from a_os_lang_stls
where swb_number = p_sb_no
and PC_FLAG = 'C';
Could someone please help me how to convert the value separated by commas in a comma separated value new map to another table and pass it as part of the sys_refcursor.
Thanks in advance.
Kind regards
SB2011
Hello. Here are the queries for the two sys_refcursors.
(1) FOR THE FLAG = 'P '.
SELECT T1.ID,
T1. SWB_NUMBER,
T1. PC_NUMBER,
T1. PC_FLAG,
T1. INSTALLATION_ORD,
T1. SP_OR_LATER_VSN,
T1. PLATFORM,
T1. OS_CODE,
T2. LANG_CODE
DE)
SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,AG_OSCODE,',')). Extract ('//Text ()'), ',') OS_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() os_id
Of a_os_lang_stls t, xmltable (os) t1) T1.
OS_dtls T2
WHERE T2.ID = T1. OS_ID
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T1 PLATFORM),
(SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,LANGNAME,',')). Extract ('//Text ()'), ',') LANG_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() lang_id
Of a_os_lang_stls t, xmltable (lang) t1) T1.
lang_dtls T2
WHERE T2.ID = T1.lang_id
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T2 PLATFORM)
WHERE T1.ID = T2.ID
AND T1. SWB_NUMBER = T2. SWB_NUMBER
AND T1. PC_NUMBER = T2. PC_NUMBER
AND T1. INSTALLATION_ORD = T2. INSTALLATION_ORD
AND T1. PLATFORM = T2. PLATFORM
AND T1. PC_FLAG = "P";
(2) PC_FLAG FOR = 'C '.
SELECT T1.ID,
T1. SWB_NUMBER,
T1. PC_NUMBER,
T1. PC_FLAG,
T1. INSTALLATION_ORD,
T1. SP_OR_LATER_VSN,
T1. PLATFORM,
T1. OS_CODE,
T2. LANG_CODE
DE)
SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,AG_OSCODE,',')). Extract ('//Text ()'), ',') OS_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() os_id
Of a_os_lang_stls t, xmltable (os) t1) T1.
OS_dtls T2
WHERE T2.ID = T1. OS_ID
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T1 PLATFORM),
(SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,LANGNAME,',')). Extract ('//Text ()'), ',') LANG_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() lang_id
Of a_os_lang_stls t, xmltable (lang) t1) T1.
lang_dtls T2
WHERE T2.ID = T1.lang_id
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T2 PLATFORM)
WHERE T1.ID = T2.ID
AND T1. SWB_NUMBER = T2. SWB_NUMBER
AND T1. PC_NUMBER = T2. PC_NUMBER
AND T1. INSTALLATION_ORD = T2. INSTALLATION_ORD
AND T1. PLATFORM = T2. PLATFORM
AND T1. PC_FLAG = 'C ';
-
Procedure with input output and num_array sys_refcursor
Hello
I have to write a procedure with input of type of parameter num_array which will forward a list of IDs to the procedure and the output is sys_refcursor that will pass the id with the other columns in the table to the list of identifiers.
operating system is the table with the id, os_name column with more than a few columns.
create table os
(identification number,
OS_name varchar2 (30),
.. .few more columns);
I spend the os_name with id through the sys_refcursor.
So I created the following procedure.
num_array is a type of data defined by the user that is created as follows:
create or replace type num_array in the table to the number;
/
create or replace procedure get_os_lang_dtls (num_array, id_os sys_refcursor id_num)
is
Start
/ * oses is the main table with id, os_name with other columns
/ * oses_gtt is the temporary table with id number data type varchar2 os_name * /.
for indx in 1.id_num.count
loop
insert into os_gtt
SELECT id, os_name
of the operating system
where id = id_num (indx);
end loop;
commit;
Open the id_os for
Select * from os_gtt;
end;
/
I created a global temporary table with the column id and os_name.
Insert in this table by using the id of i / p and setting os_name recovery operating system for this id in the loop.
Then I open the exit sys_refcursor.
Could someone please suggest me a better way to write the same logic?
Thanks in advance
No need of the TWG or anything too flashy here.
Since you have a SQL type, you should be able to get away with...
open out_ref_cursor for select
from os, table(cast(id_num as num_array)) nu where os.id = nu.column_value; A couple of notes apart from that. ID is not a great name for a column, why not OS_ID to be online with your OS_NAME? Second, always try to avoid use of the TWG, they are handy once in awhile, but not required nearly as often as find you them.
A "rebate" in the casting of tables like that and their use in SQL is the cost based optimizer usually (depending on version) has no idea of how to do to optimize the query (it has no statistics on the table as it does on a table). In General, if you know that you have X items in this table, it is better to say Oracle. You can use the CARDINALITY indicator to tell Oracle about the number of lines, you expect your table to have on average. The default proposal is going to be your block size, so assuming that 8 k (standard) the estimate is going to be like 8000 items... probably not close to reality.
See you soon,.
-
How to call a procedure with parameter SYS_REFCURSOR OUT
Hello
With the help of Oracle 11 g R2.
I would like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor) as begin open result for select 1 from dual union all select 2 from dual; end;
I want to call this procedure similar to how a query is called and executed. Like this
Select * from testprocedure
I have seen lots of examples on the web that show how it is possible to loop through the results of a sys_refcursor inside an anonymous block and display the results using dbms_output.putline, but this isn't the method I'm looking for.
Read this: PL/SQL 101: understanding Ref Cursor
You're wrong if you think a ref cursor is a result set of data that you can query from.
-
Hello
I have the following code built using idocScript
< $dDocName = $NomVariable >
< $executeService ("DOC_INFO_BY_NAME") $ >
Note: NomDeLaVariable value contentID for that 'DOC_INFO_BY_NAME' has to be executed.
When I run this, I see that DOC_INFO_BY_NAME is getting executed for an ID of previous content that he was 'dDocName '. In other words, after allocation
< $dDocName = $NomVariable >
Does not take effect.
I think that the value is not updated in the binder. How can I fix it.
It is bit urgent, any help would be greatly appreciated.
Thank you and best regards,
Steven K.
rsBlogPostings (copy of results of research) already has dDocName column and when you call executeService in a loop, resultset a preference on the local data. (I faced something similar and had no luck with #local.dDocName)
(1) you can renmae the dDocname column in the rsBlogPostings using rsRenameField
(2) if it does not, create your own loop as below
<$iCountEnd =="" rsnumrows("rsblogpostings"),="" icountstart="1$">
<$exec rsfirst("rsblogpostings")$="">
<$loopwhile lcountstart="">$loopwhile><= lcountend$="">
<$postAuthorImageEntry = ="" ssincludexml(rsblogpostings.ddocname,="" "blog_entry/authorimage/node()")$="">
...
...
<$dDocName=authorContentID$>
<$executeService("DOC_INFO_BY_NAME")$>
<$exec rsnext("rsblogpostings")$="">
<$lCountStart =="" lcountstart="" +="" 1$="">
<$endloop$>
$endloop$>$lCountStart>$exec>$executeService("DOC_INFO_BY_NAME")$>$dDocName=authorContentID$>$postAuthorImageEntry>=>$exec>$iCountEnd>
Maybe you are looking for
-
Have bought several albums on iTunes from a 3 month and although the album will appear in my iPod classic 160 gb, there is no content. I you select the album in the playlist, and it opens with 0 content. Apple have not solved this problem as yet some
-
HP Pavilion DM3 1100: HP DM3 1100 hybrid series and Windows 10 compatibility chart
Hello! I am running W7HP x 64 on my DM3 of Pavilion with hybrid graphic system (Mobile Intel 4 series) and GeForce G105M. I'm worried because I'm not sure that the hybrid function works - which means that it will pass graphics cards according to the
-
COMO BAJO UNA CAMARA CANON 20 D DIGITAL FOTOS A WINDOWS XP
AS I HAVE THAT TENER EN MI PC PARA BAJAR UNA CAMARA CANON 20 D DIGITAL FOTOS A WINDOWS XP? AGO THAT NO PUEDO HACERLO, DÁ THE CAMARA HAS THE COMPU Y NO. PASA NADA EN (MI PC) NO. RECONOCE LA, TENRE THAT INCLUDE ALGUN PROGRAMA? GRACIAS, BRENDA SOYA
-
No sound video and game not listed in the Manager of devic not vista audio output installed
Sound has been one after some updates has exploded. already updated deleter - 94
-
Type of device, DVD/CD Rom drives Manufacturing (Standard CD Rom Drive) Location Bus number 1, target 1 lun 1. 0 My computer repeat myself that everything is up to date and works fine Thanks in advance