How to read my ref cursor return user defined cursor type
HelloI have the types defined as follows:
TYPE MY_RECORD IS RECORD (
COL1 TABLE1.COL1%TYPE,
COL2 TABLE1.COL2%TYPE
);
TYPE MY_CURSOR IS REF CURSOR
RETURN MY_RECORD;
It is used as a return type in a stored procedure.I have a pl/sql block, where I make a call to MS that returns this cursor.
How to read individual values for SP?
SQL> create or replace package pkg
as
type my_record is record (col1 emp.empno%type, col2 emp.ename%type);
type my_cursor is ref cursor
return my_record;
procedure p (cur out my_cursor);
end pkg;
/
Package created.
SQL> create or replace package body pkg
as
procedure p (cur out my_cursor)
as
begin
open cur for
select empno, ename
from emp
where rownum <= 2;
end p;
end pkg;
/
Package body created.
SQL> declare
cur pkg.my_cursor;
e_rec pkg.my_record;
begin
pkg.p (cur);
loop
fetch cur into e_rec;
exit when cur%notfound;
dbms_output.put ('Empno: ' || e_rec.col1);
dbms_output.put_line ('; Ename: ' || e_rec.col2);
end loop;
close cur;
end;
/
Empno: 7369; Ename: SMITH
Empno: 7499; Ename: ALLEN
PL/SQL procedure successfully completed.
Tags: Database
Similar Questions
-
How to get user defined Native Types is displayed
I added a new user defined native Type using type Admin
I saved, closed and then reopened the Data Modeler, but he does not appear in the Source Type drop-down list when I define a column in the relational model. I've defined the relational model to use 12 c as the Site of RDBMS. Am I missing a step in the installer?
I use 4.1.3 on a Mac.
Hello Kent,
the native DB types never appear in the column definition. You need to create the new type of logical data and map it to the native type or change the mapping of logical type existing. The steps are confusing because it's like the problem or chicken (which is the first), you you will be defined first:
(1) define the native type - save definitions - defined by the user of the native types had to be saved in order to be available for native types logic mapping
(2) identify the type of logic - probably VARIANT in your case, define the mapping of native type logic
(3) in native type definition define the mapping of native code to the logical type (it is mapped on the CLOB type on your photo - probably you will change it)
(4) save the definitions
Philippe
-
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 create a REF CURSOR from the static values?
We call for a program of power supply (from PL/SQL) that returns a string with data (separated by {}), lines like this:
Our PL/SQL procedure should exit a REF CURSOR with lines like this:{packetId:236,packetName:ADSL-320K-1M-3G}, {packetId:257,packetName:ADSL-1024K-1M-20G}, {packetId:232,packetName:ADSL-INTERANET-UNLIMITED}, {packetId:234,packetName:ADSL-512K-3M-16G}, .................. ......... .....
How do this pls?236, ADSL-320K-1M-3G 257, ADSL-1024K-1M-20G 232, ADSL-INTERANET-UNLIMITED 234, ADSL-512K-3M-16G ......... ......
Published by: Channa on May 18, 2012 02:30Hello
Channa wrote:
It's the first gives ORA-00942: table or view does not exist for the FROM t . When I can replace the t split_t , I get ORA-32031: illegal reference to a query with the term name.What is at stake here pls?
Use the name of your real of the table where I used t.
If you don't have a table, just a string, then select the double. -
How to pass a REF CURSOR from a function
I tried to compile the following function:
CREATE or REPLACE FUNCTION example
RETURN REFCURSOR
IS
heart REFCURSOR;
BEGIN
OPEN FOR heart
"SELECT x FROM table";
RETURN cur;.
END;
but I get:
PLS-00201: identifier 'REFCURSOR' must be declared.
Can you help me in the right syntax? I never return a REF CURSOR to a function.
Is my Version of Oracle 8.1.7
Thank you!You cannot use SYS_REFCURSOR in Oracle 8i.
The work is approximately as followscreate or replace package my_pk as type my_cur is REF CURSOR; end my_pk; -- Now write your function create or replace function my_func return my_pk.my_cur as l_cur my_pk.my_cur; begin open l_cur for select * from table_name; return l_cur; end my_func;
Thank you
Andy -
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 the Ref Cursor runtime error
Hello everyone,
the code as follows
When I run this code im gettingcreate 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;
can you please help me get rid of this problem.ORA-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
thanking you,
Prakashd_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.
-
The stored procedure PL/SQL - t - it accept the custom Ref Cursor type?
I am not able to compile the following procedure in the HR schema comes with default oracle... I use Oracle 11g Release 11.2.0.2.0 Express edition. It gives me an error (given after the code block):
Block of code:
CREATE OR REPLACE PROCEDURE TEST_REF IS
DECLARE
TYPE REF_EMP IS REF CURSOR RETURN % ROWTYPE EMPLOYEES;
RF_EMP REF_EMP;
V_EMP EMPLOYEES % ROWTYPE;
BEGIN
DBMS_OUTPUT. ENABLE (1000000);
OPEN FOR RF_EMP
SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID > 100;
EXTRACT THE RF_EMP IN V_EMP;
DBMS_OUTPUT. PUT_LINE (V_EMP. FIRST_NAME. ' ' || V_EMP. LAST_NAME);
CLOSE RF_EMP;
EXCEPTION
WHILE OTHERS
THEN DBMS_OUTPUT. PUT_LINE (SQLERRM);
END TEST_REF;
/
Error:
Errors in PROCEDURE TEST_REF:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/1 PLS-00103: encountered the symbol "DECLARE" when waiting for an a
What follows:
Start function < an ID > pragma procedure subtype type
< between double quote delimited identifiers > delete the current cursor
There are the external language prior
The symbol 'start' is substituted for 'DECLARE' continue.
16/13 PLS-00103: encountered the symbol "end-of-file" when waiting for him
one of the following values:
(begin case declare exit end exception for goto if loop mod)
pragma raise return null select update while withGet rid of the DECLARED:
SQL> CREATE OR REPLACE PROCEDURE TEST_REF IS 2 TYPE REF_EMP IS REF CURSOR RETURN HR.EMPLOYEES%ROWTYPE; 3 RF_EMP REF_EMP; 4 V_EMP EMPLOYEES%ROWTYPE; 5 BEGIN 6 DBMS_OUTPUT.ENABLE(1000000); 7 OPEN RF_EMP FOR 8 SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID > 100; 9 FETCH RF_EMP INTO V_EMP; 10 DBMS_OUTPUT.PUT_LINE(V_EMP.FIRST_NAME || ' ' || V_EMP.LAST_NAME); 11 CLOSE RF_EMP; 12 EXCEPTION 13 WHEN OTHERS 14 THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); 15 END TEST_REF; 16 / Procedure created. SQL> set serveroutput on SQL> exec TEST_REF; Donald OConnell PL/SQL procedure successfully completed. SQL>
SY.
-
How to use the negation in the user defined rules?
Hello
Can you please show me an example using negation in the rule set by the user? I created a rule like below (the rule says that if a patient has a fever problem and not having penicillin hypersensitivity, then recommend medication1):
INSERT INTO mdsys.semr_myMedicineRB VALUES ('rule1',
' (? p RDF: type: Patient) (? p: present? c1) (? c1 RDF: type: fever) (? c2 RDF: type: Penicillin_Hypersensitivity)',
"(NOT_EXISTS (p: present c2))',
' (? p: recommendation: medication1)',
SEM_ALIASES (SEM_ALIAS (",'http://www.example/medicine#')));
The rule correctly applied in the modules. However, I cannot move to the phase of creation entailment and got errors:
ORA-29532: Java call terminated by eception Java exception: java.sql.SQLException: parameter IN or OUT to missing index: 1
ORA-06512: at the 'MDSYS. SDO_SEM_INF_INTERNAL', line 16453
ORA-06512: at the 'MDSYS. SDO_SEM_INFERENCE', line 302
ORA-06512: at the 'MDSYS. SDO_SEM_INFERENCE', line 352
ORA-06512: at the 'MDSYS. RDF_APIS', line 118
ORA-06512: at line 2
29532 00000 - "Java call terminated by eception Java exception: %s."
* Cause: A mistake or a Java exception has been reported and could not be
solved by Java code.
* Action: Modify Java code, if this behavior is not expected.
According to the post
, it seems that negation is not supported in rules defined by the user. Can you please advice how to implement the negation in the rules defined by the user? Thank you very much in advance.Hong
Salvation Hong,
Negation is not supported in rules defined by the user. If you need a work-around, please follow the suggestion in the post you referenced.
If you use Oracle Database Release 12 c, user-defined inference can certainly manage negation.
It will be useful,
Zhe Wu
-
I don't understand. What is the point of having a cursor type at all if the cursor position doesn't look like whatever the point type will begin in? I checked all the Options in the type menu and any leader is zero, so there is no lag anywhere, but when I click on a particular spot on the page, it's because that's where I hope to see the type. What a laugh! No placement type correct, will never be. It must be scooted in place. using the arrow. Is it possible to make the entry point makes it a resemblance to the point ' by clicking on '?
I don't see a problem:
Your paragraph palette has something inside in addition to zeros? My guess is that you have left a big indent in the first field.
-
CS5.1: How to create a new swatch palette 'User Defined'.
CS5.1: Sub window 'Libraries of nuances', 'User Defined' is grayed out so I can't access my palette personal swatch. I have the data to recreate it, but can't find a "new palette" selection.
Thanks Monika. Your answer has led me to what seems to be a success. I opened an existing file that had my palette of integrated shade inside, and then selected "Save Swatch Library as HAVE", giving it the name of my swatch palette. This palette will now appear under "User Defined".
-
How to recognize an exception with JDBC user-defined?
When you call this (or a similar procedure) with JDBC *, I get just a general java.sql.SQLException: ORA-06510: PL/SQL: not supported by the user-defined exceptiondeclare x exception; begin raise x; end;
Is there a way to get more information about the exception?
Then the client code can tell one from the other.
* Spring JDBC actuallyGiven this pl/sql block, he has nothing else to report, you raise just a generic exception. Try something more like:
begin raise_application_error(-20001, 'Something bad happened'); end;
or, if you really want the e
declare x exception; begin raise e; exception when e then raise_application_error(-20001, 'E happened'); end;
John
-
Initialize a constant which is a user-defined record type
Hi all
This may be a simple question, but I'm hard-pressed to find a solution.
The PL/SQL documentation says I can declare a constant from a defined record type previously. But how to initialize in the declaration? For example.
create or replace package my_package as
type my_type is record (varchar2 (10) Field1, Field2 varchar2 (10));
c_myconst constant my_type: = < what? >;
end my_package;
I tried the initialization function that does nothing more to return one my_type with the fields defined and which works except that PL/SQL has a restriction that this feature cannot be in the same package that the constant that will make my packages appear disorganized - I would be just as quickly initialize the constant online so down the line , programmers are not wondering why I call this function only in its own packaging.
Is a syntax that will allow me to provide values for the c_myconst must in the declaration?
Thank you
JohnI checked - declare the INIT_ERR() function before using it to fill the constant makes no difference: it precipitates again PLS - 492.
so the SQL Types seem the way to go...
SQL> create or replace type err_type as object 2 (err_num number(5,0), err_msg varchar2(200)); 3 / Type created. SQL> SQL> SQL> create or replace package app_errs as 2 3 function init_err(p_err_num in pls_integer, p_err_msg in varchar2) 4 return err_type; 5 6 c_bad_id constant err_type := err_type(-20000, 'Invalid ID'); 7 8 procedure raise_err(p_err_num in pls_integer, p_err_msg in varchar2); 9 10 end app_errs; 11 / Package created. SQL>
Cheers, APC
blog: http://radiofreetooting.blogspot.com
-
How to read the Drwtsn32.log and user.dmp files
I'll have the blues of the blue screen and need to read these files to help me find the problem.
I found the problem
NVIDIA GeForce4 MX 420 with AGP8X
as he tried to update last update driver was, but wouldn't Toad. I'm incotact with the support of tec awaiting a response
Thank you for answer
-
How to change name of the listener (user Defined) for OEM
Hi all
We have created a different listener as auditeur1, now when we start ORacle Enterprise manager, it is show theerror
Earphone
Down status
Home eSVCS-DB-PRD1
Port 1521
Name LISTENER
/Oracle/product/10.2.0 oracle Home
Location /oracle/product/10.2.0/network/admin
TNS-12541 details: Listener TNS:no
Connection to the Instance of the agent
State has failed
Details ORA-12541: Listener TNS:no (DBD ERROR: OCIServerAttach)
Please let me know how to apply the new Manager Oracle Enterprize listener.
We use the oracle database 10.2.0.3 on SunOS (sun4v sparc SUNW, SPARC-Enterprise-T5220)
Thank you
Ankit.Send me the contents of this file.
Check in the file emoms.properties
and also check in the targets.xml file
Published by: CKPT December 27, 2010 09:54
Maybe you are looking for
-
"Device Access Manager" crashes
I've got V 8.3.4.1811 HP customer security pre-installed on my new ProBook G2 of 450. However when I try to access the "Device Access Manager" the program hangs and displays this error: "at HP. ProtectTools.DeviceAccessManager.BaseViewModel.Load)at H
-
The jet office 4315 all-in-one: printer plug on the Tablet?
I have an apex Tablet and I would like to know if there is a way to connect my all in one printer for her so I can print from my tablet, I have a cord to hang them together but I'm assuming that could print from the tablet should I make the tablet to
-
Battlefront II installation problems: Windows 7
Star Wars Battlefront II will not install on my gaming laptop later. A pop up comes up saying there is a problem with Vista, launch the game, I click on OK, and no other installation window appears. No idea why he moved?
-
New: Audiobooks and ID3 and Fuze
Hello I want to use the "rocket" listen to audio books. I heard Sansa players are very good for this aproach. Now I have tagged all my audio books with ID3 tags, but the player don't always play them in the right order. The directory structure is "Na
-
Remote Desktop connection options are not available
Original title - Remote Desktop connection Im trying to use the remote desktop connection, but when I go to test to enable it, it won't give me the three options at the base that are: 1 do not allow connections to this computer 2 allow the connection