How to perform procedures with REF CURSOR &; PLSQL settings table in SQL Dev?
I have 3 SQL Developer. I create a procedure with a set of tables/PL/SQL as an input parameter and a SYS_REFCURSOR as output parameter.When I press the green arrow (Run button) block the dialog box run PL/SQL PL/SQL has no place at the PL/SQL table with records of entry and also to see the output of the SYS_REFCURSOR.
I get the error ORA-06550 and many other errors when I run the present.
How to do this please?
In the debug code, lose the ABS. Prefix the SYS_REFCURSOR QC_SQL_DEVELOPER_TEST.
Also, do not use same name of your settings on your bind variable (so e.g.: OUT_REF_CURSOR).
REF CURSOR is supported output types, so you will get the output of their share in the output tab.
However the output system does not recognize your own types as your PL/SQL table. You need to write an exit procedure yourself, indexing correctly, using the DBMS_OUTPUT.
Have fun
K.
Tags: Database
Similar Questions
-
How to run the packaged procedure with Ref Cursor
Hello.
The question may be very simple for you... but I was confused how to run
I have the following package
But I want to test (run) this procedure...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); 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; END CURSPKG; /
But confused how to have Ref Cursor
Could you help me in this...
Thank youYou must declare a variable of type T_CURSOR and pass it to the procedure like this.
declare lOutCursor CURSPKG.T_CURSOR; begin CURSPKG.OPEN_ONE_CURSOR(
, lOutCursor); end; -
How to perform procedure with parameter?
Hello
I have a procedure as below,
CREATE or REPLACE procedure SYS.reset_procede_user (p_username varchar2)
is
DEFAULT_PASSWORD constant varchar2 (64): = "Hello1";
v_dummy varchar2 (128);
v_user varchar2 (30): = upper (trim (p_username));
CTX varchar2 (128);
Start
CTX: = "checking if active user ['|]" [v_user |'] There are in the process ';
Select firstname. » '|| LastName in v_dummy
of pesdbo.systemuser
where logonid = v_user and userstatus = "A";
CTX: = ' checking if ['| v_user |'] is locked or expired ";
for r in (select * from dba_users where)
username = v_user and
(account_status as account_status like '% EXPIRED' or 'LOCKED %')
)
loop
CTX: = ' unlock ['| v_user |'] account ';
run immediately 'edit user' | v_user | "account unlock;
end loop;
CTX: = "profile setting default ['|]" [v_user |'] ' ;
run immediately 'edit user' | v_user | "default profile";
CTX: = ' password for default ['| v_user |'] ' ;
run immediately 'edit user' | v_user |' identified by ' ' |. ' DEFAULT_PASSWORD |' » ' ;
-ctx: = ' password expires ['| v_user |'] ' ;
-immediate execution "edit user" | v_user | "password expiration";
CTX: = ' profile of ARMONK setting for ['| v_user |'] ' ;
run immediately 'edit user' | v_user | "profile armonk;
exception when others then
raise_application_error (-20001, ' reset_procede_user ("' | ')) v_user | ("'"): ctx('||) CTX |') : ' || SQLERRM());
end;
/
How can pass parameter, like (CR6666) to run this stroed procedure?
I try as
declare
CR6666 varchar2 (20);
Start
reset_procede_user (CR6666);
end;
but does not work well...
Something wrong? (we suppose to use this procedure to reset the password of the user, now a user called CR6666 want me)
to reset using this procedure)
Thank you very much
Kind regards
Jerry
Published by: jerrygreat on April 10, 2009 08:03Hello
I think you need to change your procedure here:
CREATE OR REPLACE procedure SYS.reset_procede_user (p_username IN varchar2) -- missed IN here
And to be executed, that:
declare p_username varchar2(20); begin p_username:='CR6666'; reset_procede_user (p_username); end;
Thank you
Published by: user10679113 on April 10, 2009 08:15
-
Hello all;
Can you please show me a simple example on how to join a Ref cursor to a table, because I have a function that returns a Ref Cursor and I want to call this function in another function (B) and then he join a table in this function (B)How do I join a Ref cursor to a table
I can do on my 11 GR 2
SQL> declare c sys_refcursor; l_ename emp.ename%type; begin open c for select * from dept where loc = 'DALLAS'; select ename into l_ename from emp, xmltable ('ROWSET/ROW' passing xmltype (c) columns deptno number path 'DEPTNO') x where emp.deptno = x.deptno and rownum = 1; dbms_output.put_line (l_ename); end; / SCOTT PL/SQL procedure successfully completed.
-
DbDataAdapter and stored procedures with Oracle cursors,
Because of the problems I've mentioned here ([PL/SQL stored procedure causes OracleException.. .but only sometimes | https://forums.oracle.com/forums/thread.jspa?threadID=2267290]), I am trying to replace a specific layer of data ODP.NET with the code that uses the related classes, independent provider and DbProviderFactory. Things seemed to go right up to the point where I'm trying to use a DbDataAdapter object to fill a DataSet. The stored procedure, I call looks like this...
/* - - - - - - - - - - - - - - - - - - - - */
PROCEDURE GET_SOME_DATA)
IN_PARAM1 IN VARCHAR2,
O_RESULTS TO SYS_REFCURSOR);
/* - - - - - - - - - - - - - - - - - - - - */
Normally, I could do something like this...
/* - - - - - - - - - - - - - - - - - - - - */
var adapter = new OracleDataAdapter (cmd);
adapter. Fill (ds, cmd (OracleRefCursor). Parameters [1]. (Value);
/* - - - - - - - - - - - - - - - - - - - - */
.. .but that is not possible when you use DbProviderFactories since there is no equivalent of the Ref Cursor. I can use a DbDataAdapter instead of an OracleDataAdapter object, but I can't understand how to fill it with the cursor. All the examples I've seen (even the specific Oracle ones) seem to assume one is writing queries like "SELECT FOO FROM BAR" or something like that.
Am I going about this all wrong? Or is it simply not possible to use a DbDataAdapter to fill a DataSet like this? I was really hoping to be able to use the provider-independent code I could use the System.Data.OracleClient provider with my 9i database and then switch to the Oracle. DataAccess.Client once we have upgrade to 11g. Looks like I'll have to completely replace the data layer code and references. I knew that the former was necessary, but I hope this could be managed by interfaces of independent provider with concrete implementation changed via the config and/or my IoC container.
NOTE: I found this thread in the forums, but the posters to stop before the point at which they return the sliders and make use of them: [ODP.Net Ref Cursor and DbProviderFactory | https://forums.oracle.com/forums/thread.jspa?messageID=1278007]
Thank you!I did yesterday a similar thing.
The code was specific ODP.NET (that always, it is and should be), but I didn't rely on a reference to Oracle.DataAccess directly in my particular case:
The code I ended up with is not very pretty, but it works.
var refCursorType = Enum.Parse (((dynamic) plant.)) CreateParameter()). OracleDbType.GetType (), "RefCursor");
dynamic oracleParameter4 = factory. CreateParameter();
oracleParameter4.Direction = ParameterDirection.Output;
var piInstance = oracleParameter4.GetType (). GetProperty ("OracleDbType");
piInstance.SetValue (oracleParameter4, refCursorType, null); -
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 create a procedure for REF CURSOR output with any WHERE clause?
I have a requirement like this: I have a huge question that need to reuse in my code over 10 times. This SQL has about 50 lines. Here for these 10 odd times sometimes changes in WHERE clause (columns are the same). So I can't create a view as SQL is not static.
I thought to write a procedure with a para of WHERE_CLAUSE entry. I pulled out a refcursor sys by adding where clause. But I can't do it because you cannot add a clause like this where clause.
i.e.
The foregoing gives an error.PROCEDURE dynamyic_query (p_where_clause IN VARCHAR2, p_out_query OUT SYS_REFCURSOR ) IS BEGIN OPEN p_out_query FOR SELECT ......... FROM table WHERE || ' ' || p_where_clause; END;
How to handle such a situation? Any help would be greatly appreciated.Hello
Channa wrote:
... However, when I change the procedure like this:PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS v_stmt VARCHAR2(1000); BEGIN v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND :y'; OPEN p_out_cursor FOR v_stmt using p_where_cluase; END;
And run this block of code:
declare v_tname varchar2(200); out_cursor sys_refcursor; begin forms_text_dyn_sql_test(' 1 = 1 ', out_cursor ); LOOP fetch out_cursor INTO v_tname; exit when out_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE(v_tname); END LOOP; end; /
I get the error:
[1]: (Error): ORA-00920: invalid relational operator ORA-06512: at "ABS.FORMS_TEXT_DYN_SQL_TEST", line 6 ORA-06512: at line 5
Looks like you can only set column_name =: z, column_name =: values of type y. You can not it seems to replace it with no WHERE CLAUSE?
A bind variable, such as: it, represents a single value.
If: is the VARCHAR2 '1 = 1', thenSELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND :y
takes the value
SELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND '1 = 1'
I think you want something like this:
CREATE OR REPLACE PROCEDURE FORMS_TEXT_DYN_SQL_TEST ( p_where_clause IN VARCHAR2 , p_out_cursor OUT SYS_REFCURSOR ) IS v_stmt VARCHAR2(1000); BEGIN v_stmt := 'SELECT ename FROM scott.emp WHERE ename LIKE ''%A%'' AND ' || p_where_clause; OPEN p_out_cursor FOR v_stmt; END; / show errors SET SERVEROUTPUT ON declare v_tname varchar2(200); out_cursor sys_refcursor; begin forms_text_dyn_sql_test(' 1 = 1 ', out_cursor ); LOOP fetch out_cursor INTO v_tname; exit when out_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE(v_tname); END LOOP; end; /
Output:
ALLEN WARD MARTIN BLAKE CLARK ADAMS JAMES
-
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.
-
Made Oracle 6i LOV with ref cursor returned by a function of database
Hi all
I want to dynamically create a LOV in oracle forms 6i using the value of ref cursor returned by the function of database.
is this possible?
Using loop, I could able to display the values returned by the ref cursor, but how can I assign these values in the LOV?
You will need to loop through your REF Cursor and assign each value to a group of registration of forms and then assign the Group Record to your LOV. Take a look at the built-ins CREATE_GROUP, ADD_GROUP_COLUMN and ADD_GROUP_ROW in the help system of forms for more information about how to use these built-ins and examples of how to use them.
Craig...
-
Error when you work with Ref Cursor
Hi, I tried the following, but the err
Error isDECLARE TYPE ref_nm IS REF CURSOR; vref REF_NM; vemp emp%rowtype; BEGIN OPEN vref FOR SELECT ename ,sal FROM EMP; LOOP FETCH vref INTO vemp; EXIT WHEN vref%NOTFOUND; DBMS_OUTPUT.PUT_LINE ( vemp.ename ||','||vemp.sal ); END LOOP; CLOSE vref; END;
ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
Use you this structure as a buffer of extraction:
PEMV emp % rowtype;This structure contains the whole line of EMP - all columns.
That's what you're looking for cursor - 2 columns (not the whole line):
Vref OPEN for SELECT ename, sal of EMP;You can not expect from PL/SQL to find out how to move the 2 column values in a structure that has more than just 2 columns. The error message is quite clear about this - read and think what is transport of the error.
-
problem with writing a procedure with the name of the table as an input parameter
Hi all
I am writing a procedure with the table name as input parameter:
Here is the code
create or replace procedure CEP (in_tbl in varchar2)
as
Start
run immediately 'truncate table tlb;
Insert into tbl
Select a, b, c of in_tbl;
end;user579585 wrote:
Hi allI am writing a procedure with the table name as input parameter:
Here is the codecreate or replace procedure CEP (in_tbl in varchar2)
as
Startrun immediately 'truncate table tlb;
Insert into tbl
Select a, b, c of in_tbl;
end;
You will also need to use dynamic sql for insert statements:
execute immediate 'begin insert into tbl select a,b,c from '||in_tbl||'; end';
-
NamedStoredProcedure with Ref Cursor output
I would like to install a NamedStoredProcedureQuery who can receive results of a cursor, and I wonder if it's possible.
So I have my procedure:
procedure test_proc (t_cursor ON ref_cursor)
is
Start
Open the t_cursor for
Select * from enrolment;
end;
and my NamedStoredProcedureQuery:
@NamedStoredProcedureQuery (name = "TEST_REF_CURSOR", procedurename = "TEST_REF_CURSOR.test_proc", returnsResultSet = true,
parameters = {@StoredProcedureParameter (queryParameter = "t_cursor", name = "t_cursor", direction = Direction.OUT_CURSOR, type = Enrolment.class)})
So I try to call my Proc with:
Query query = em.createNamedQuery ("TEST_REF_CURSOR");
List results = query.getResultList ();
and I get a oh so helpful error:
Inner exception: java.sql.SQLException: ORA-00900: invalid SQL statement
Error code: 0
Call: BEGIN TEST_REF_CURSOR.test_proc (t_cursor = >?); END;
link = > [= > t_cursor]
I'm doing something wrong or should I use StoredProcedureCall instead?It should work.
The question seems to be
returnsResultSet = true,
delete it, or set it to false.
---
James: http://www.eclipselink.org -
Call a procedure stored via JDBC with a REF CURSOR * input variable.
Hello
S/n of my client has provided me with a stored procedure that I need to call to get information about products prices. Something along the lines of:
some_package.getPrices (products IN OUT csr_type);
where csr_type represents a REF CURSOR. This cursor has a product ID column and a price column. The plan is to move the cursor with the populated product id column and have the routine decorate the slider with the prices.
The setting in this plan is that it seems that it is not possible to go from JDBC REF CURSOR in . However, I'm not sure, since I can only find throw comments on various forums (e.g. http://www.orafaq.com/forum/t/35088/0/), without any reference. If I go back to the client and tell them that their idea will not work, I prefer to be able to point them to a documentation somewhere
So I guess my questions are:
1. it is indeed impossible to pass a REF CURSOR type as a variable input on JDBC to a stored procedure?
2. is there information I can do about my client?
3. am I on the right track thinking I need to go down the path of an array of objects?
Thank you very much to anyone who can help
Peter Svehla.Hi Peter,.
I see it, missed that you actually want to pass in a list of products. Don't think that you can do this with the current procedure. A slider is just a pointer to a result set.
How the result set is created and what it looks like, is determined when the cursor is opened.What does this procedure with the cursor? -It does not have some OPEN
TO ; inside? Or, perhaps, you are supposed to send in an open cursor (does not much sense to me)?
Concerning
Peter -
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
-
stored procedure with cursor as param output
This is the first time for me to test a stored procedure with a cursor as an out parameter. I performed the following:
SQL > user_cur VARIABLE REFCURSOR; VARIABLE ret_code VARCHAR2; exec TEST_API. SEARCH_USER (: ret_code, ",", "John", ",: user_cur); print ret_code; print user_cur;
I got the following error:
Use: VAR [IABLE] [< variable > [NUMBER |]] TANK | CHAR (n [CHAR |]) BYTE]) |
VARCHAR2 (n TANK). NCHAR. NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR]]
Can I know what is the problem?
The purpose of the stored procedure is looking for user with the name 'john '.
The declaration of input/output params to stored procedure is as follows:
PROCEDURE SEARCH_USER
(
RETURN_CODE OUT VARCHAR2,
USER_ID_IN IN VARCHAR2,
POSITION_IN IN VARCHAR2,
USERNAME_IN IN VARCHAR2,
STATUS_IN IN VARCHAR2,
USER_CUR_OUT ON REFCURSOR
)
Published by: user7383310 on October 19, 2008 21:05
Published by: user7383310 on October 19, 2008 21:05refer here for the use of refcursors in pl/sql...
http://download.Oracle.com/docs/CD/B14117_01/AppDev.101/B10807/06_ora.htm#sthref808You can code as...
SQL> create or replace procedure p1(id number,csr out sys_refcursor) is 2 begin 3 open csr for select ename from emp where deptno = id; 4 end; 5 / Procedure created.SQL> var csr1 refcursorSQL> var n numberSQL> exec :n := 30; PL/SQL procedure successfully completed. SQL> exec p1(:n,:csr1); PL/SQL procedure successfully completed. SQL> print csr1 ENAME----------ALLENWARDMARTINBLAKETURNERJAMES 6 rows selected.
Maybe you are looking for
-
I don't see my external cd in the finder under devices, I can load a blank cd and iTunes says it's white and I can burn songs, then the cd icon appears on the desktop, went into preferences for the finder and ticked the box show the cd. Help please?
-
A30 - 614, how to set memory maximum grafic?
I have a laptop A30-614. I upgraded the memory from 512 to 1024mg.Now, I try to set to its maximum MB graphics memory.Now ownership of the laptop gives me 992 MB, missing the 32 MB is for memory grafic.Manuals toshiba let's see now the graphics memor
-
Satellite P10 - USB port no longer work
Hello I have a huge problem with my computer usb portable-ports(satellite p10). After that I tried to connect my hard drive external with my laptop, all of my devices usb is lost. I tried to update all the drivers for the chipset and usb. I even upda
-
I'm sorry it is an acer aspire netbook D255E
-
I hope someone can help. Turned on my computer this morning and everything on my screen is upside down.