Calling an Oracle stored procedure that returns a REF cursor
Hi guys,.I'm calling an Oracle stored procedure that returns a REF CURSOR. Here is the piece of code that I'm working on:
procedure TC307_MAIN (p_program varchar2, varchar2, varchar2, result_set OUT eng_cur p_engchgno p_project) as
Start
IF (p_program = 'Navybased' and p_project = 'PROTECTOR-BUILD') THEN
result_set: = comments. Tc307_Eng_Chg_Rpt.TC307_RNZN (p_engchgno, result_set = >);
END IF;
end TC307_MAIN;
procedure TC307_RNZN (p_engchgno varchar2, result_set IN OUT eng_cur) as
Start
end TC307_RNZN;
PL/SQL code behind TC307_RNZN is big enough, that's why I've not stuck here. Basically, the second stored procedure executes a PLSQL statement and returns a result set. I need to return the result_set in the main proceedings based on nested else statement which I am still trying to build. I get a compilation... error can someone guide me with the correct method to call the second stored procedure and returning in the main proceedings.
Thank you very much.
Rohan,
Try this
procedure TC307_MAIN(p_program varchar2,
p_project varchar2,
p_engchgno varchar2,
result_set OUT eng_cur) as
begin
IF (p_program = 'RNZN' and p_project = 'PROTECTOR-BUILD') THEN
-- This is a procedure not a function
guest.Tc307_Eng_Chg_Rpt.TC307_RNZN(p_engchgno, result_set); --UR compilation error on this line*
END IF;
end TC307_MAIN;
SS
http://DB-Oracl.blogspot.com
Tags: Database
Similar Questions
-
How to execute a stored procedure that returns a cursor?
How to execute a stored procedure that returns a cursor?
Follow the code:
CREATE OR REPLACE PROCEDURE stp_cashin_grupo
(p_func in VARCHAR
p_cod_grup in full
p_des_grup in VARCHAR
p_logi in VARCHAR
p_curs_rset ON infoc.pck_cashin_grupo.curs_rset
)
IS
BEGIN
If p_func = "1" then
OPEN FOR P_curs_rset
Select
cod_grup
des_grup
dat_manu_grup
des_logi_manu
of infoc.tbl_cashin_grupo
order of des_grup;
end if;
END stp_cashin_grupo;
and packaging:
CREATE or REPLACE PACKAGE pck_cashin_grupo
AS
TYPE curs_rset IS REF CURSOR;
END pck_cashin_grupo;
My question is how to execute in sql plus?
Stp_cashin_grupo EXEC ('1', 0, ", '465990', my doubt is how to move the cursor as return)
Thank youIt is described in the manual
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14357/CH5.htm#sthref1122
-
Calling an Oracle stored procedure.
Stored procedures have always given me trouble, I don't know why.
I want to call a procedure from Oracle to a piece of CFML code.
My CFML code:
<cfstoredproc datasource="purload" procedure="PUR_XML_LOAD.load_raw" returncode="yes"> <cfprocparam cfsqltype="CF_SQL_FLOAT" value="999" type="out"> </cfstoredproc>
The error I get:
[Macromedia] [Oracle JDBC Driver] [Oracle] ORA-06550: line 1, column 18:
PLS-00306: wrong number or types of arguments in the call to 'LOAD_RAW '.
ORA-06550: line 1, column 7:
PL/SQL: Statement ignoredTest code PL/SQL that works with Oracle SQL Developer:
DECLARE foo NUMBER :=999; begin PUR_XML_LOAD.load_raw (foo); dbms_output.put_line('>' || foo || '<'); end;
The top of the stored procedure:
create or replace PACKAGE BODY PUR_XML_load AS -- *** PROCEDURE: PUR_XML_load *** -- Loads values from previously-validated XML file -- into the raw_pur table PROCEDURE Load_raw (res_val OUT NUMBER) AS
So, how can I make the code the same way CFML function that code PL/SQL?
TIA
Ian
OK, maybe you're RTFMing, but maybe RWAS (read this as Adam Said) ;-)
Does THIS work:
?
--
Adam
-
JPA with Oracle stored procedure: setting IN or OUT to missing index: 1
Hello
I'm going to have bad configure integration between Oracle stored procedure (which returns a cursor) and the Parliamentary Assembly joint.
Stored procedure
CREATE OR REPLACE PROCEDURE GET_ACCOUNTS_TEST
(
l_cursor on sys_refcursor
)
AS
BEGIN
L_cursor OPEN for SELECT * FROM ACCOUNTS_TEST ORDER OF ACCOUNT_NAME.
END GET_ACCOUNTS_TEST;
Oracle bean
@Entity
@NamedNativeQueries({)
@NamedNativeQuery (name = "getAccountsSP", query = "{GET_ACCOUNTS_TEST (?) call} "(, resultClass = Account.class)"
})
@Table (name = "ACCOUNTS_TEST")
Account/public class implements Serializable {}
.....
}
ManagedAccountBean
public Collection < account > getAccountsSP() {}
EntityManager em = jpaResourceBean.getEMF () .createEntityManager ();
try {}
Query query = em.createNamedQuery ("getAccountsSP");
(Collection < account >) return query.getResultList ();
} {Finally
EM. Close();
}
}
Get this error
Exception [EclipseLink-4002] (Eclipse - 2.4.0.v20120608 persistence Services - r11652): org.eclipse.persistence.exceptions.DatabaseException
Inner exception: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in the call to 'GET_ACCOUNTS_TEST '.
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error code: 6550
Call: {call GET_ACCOUNTS_TEST (?)}
link = > [null]
Query: ReadAllQuery (name = "getAccountsSP" referenceClass = sql = "{call GET_ACCOUNTS_TEST (?)}" account)
Any ideas? I can get the code to use a query in the code, but not via. an AP
Thank youThe exception occurs because you said JPA to pass a parameter, but it is not expected the stored procedure. Try to change your definition of stored proc in a cursor output variable that can be used in your JPA query to return the cursor. An example is here:
http://wiki.Eclipse.org/EclipseLink/examples/JPA/StoredProceduresBest regards
Chris -
stored procedure to return the number of rows
Hello. How can I create a stored procedure that returns a number of lines such as select count (*) of the emp. I only know how to return a result set, but how to a single value. Need help please.Easy:
CREATE OR REPLACE PROCEDURE get_count (p_count OUT NUMBER) IS BEGIN SELECT COUNT(*) INTO p_count FROM a_table; END get_count;
-
Calling a procedure that returns a cursor in a procedure
Hello
I have two stored procedures. They both return a cursor as output variables. However, I have another stored procedure that calls these procedures and return their results once again an output variable. I know that sounds strange to want to do something like this, but how can I do this?Mikhail says:
My first procedure returns a cursor. But the cursor is opened on one condition. Like, if PARAM1 = 1 THEN OPEN cursor_1 to SELECT... OTHERWISE, OPEN CURSOR_1 TO SELECT... And the second slider has the same structure. The thing is in the two procedures if I declare that a single CURSOR_1 IN OUT parameter that the procedure will not work. So in both entities, I have two variables IN OUT SYS_REFCURSOR: c1 and c2. Then, in the third procedure I first call the first procedure, then the second. How can I write my third procedure in order to obtain the result two procedures United?
Why the appellant (3rd procedure) need to have 2 ref Cursor? How will the appellant to "unite" the sliders?
The actual data, a power of work must be done inside sliders. Not in PL/SQL or other languages. The SQL language is a very powerful and flexible language.
So if the SQL 2 data sets (or more) must be "United", then you should not use the 3rd procedure and PL/SQL code to do. Should use you 2 sliders.
You should watch this by using SQL only. The 2 sets of data can be merged, joined, union'ed. You can determine the intersection. You can determine the difference (with a negative sign). It can be rotated. It can be aggregated. It can be cube' ed. Etc.
This SQL will then be used as a single slider and a unique reference cursor handle will be used to consume the output of the cursor.
The basic rule to develop Oracle applications is simple. Optimize SQL. Minimize the PL/SQL.
Use the SQL language to the data of the crisis. No PL/SQL.
-
Call a java class in my database to an oracle stored procedure oracle
my oracle stored procedure is:
create or replace
PROCEDURE openpdffile
IN THE JAVA LANGUAGE
NAME 'pdfopenbook.mainbook () ';
It is valid and so is the java class;
import java.sql. *;
Oracle.jdbc import. *;
public class pdfopenbook //class pdfopen
{
Public Shared Sub mainbook (args [] //main function) of channels
{
try try statement
{
Runtime.getRuntime () .exec ("rundll32 url.dll, FileProtocolHandler" + "c:\\temp
final_book.pdf");
Runtime.getRuntime () .exec ("rundll32 url.dll, FileProtocolHandler" + "sol.exe");
} catch (Exception e) //catch all exceptions here
{
System.out.println ("Error" + e); printing error
}
}
}
but I get the error:
onnecting to the caprs of the database.
ORA-29531: no mainbook method in the pdfopenbook class
ORA-06512: at "CAPRS. OPENPDFFILE', line 1
ORA-06512: at line 2
Process is complete.
The caprs database disconnection.
He said that there is no mainbook method, but there is, what I am doing wrong?
Thank you
DougPass the String [] as an argument to mainbook():
create or replace PROCEDURE openpdffile AS LANGUAGE JAVA NAME 'pdfopenbook.mainbook(java.lang.String[])';
Do you have posted on the forum of the database?
Kind regards
Nick
-
call to a java class of an oracle stored procedure
my oracle stored procedure is:
create or replace
PROCEDURE openpdffile
IN THE JAVA LANGUAGE
NAME 'pdfopenbook.mainbook () ';
It is valid and so is the java class;
import java.sql. *;
Oracle.jdbc import. *;
public class pdfopenbook //class pdfopen
{
Public Shared Sub mainbook (args [] //main function) of channels
{
try try statement
{
Runtime.getRuntime () .exec ("rundll32 url.dll, FileProtocolHandler" + "c:\\temp\\final_book.pdf");
Runtime.getRuntime () .exec ("rundll32 url.dll, FileProtocolHandler" + "sol.exe");
} catch (Exception e) //catch all exceptions here
{
System.out.println ("Error" + e); printing error
}
}
}
but I get the error:
onnecting to the caprs of the database.
ORA-29531: no mainbook method in the pdfopenbook class
ORA-06512: at "CAPRS. OPENPDFFILE', line 1
ORA-06512: at line 2
Process is complete.
The caprs database disconnection.
He said that there is no mainbook method, but there is, what I am doing wrong?
Thank you
Doughttp://wiki.answers.com/Q/Can_you_call_a_java_function_from_an_oracle_stored_procedure
-
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. -
Oracle stored procedure in the reports
Hello
How can I call oracle stored procedure in Oracle reports. The procedure takes a variable of type object and as a parameter out.
Thank you
GroultCreate a package in your report and set a variable of this type of object in the package body.
Write a procedure in your package that checks if your variable is empty, and if this is the case, call your db-procedure to fill the variable.
For each value that you want to display in your report, create a functioncolumn that calls the formlery procedure written in your package and then returns the requested of your object type value. In the available build ontop the columns function created fields. -
Mutex in the oracle stored procedure... How to get there?
Hello
I have the series of insert/update statements in an oracle stored procedure. The stored procedure is called composite Oracle SOA.
The procedure works like this:
a. download a request and checks to see if the file is already in the database. If she's here, we update, elsewhere insert.
b. that I check for 10 tables and make the necessary inserts/updations.
But sometimes, when I get the huge volume of transactions in the stored procedure, I see this violation of unique constraint violated due to lack of appropriate controls to ensure that no other parallel forum is trying to update the same record.
How to do this so that no two execution of stored procedure doesn't work on the same record in the same table?
Thank you!!
Hello
you might consider something like this
create table t1( id number primary key, action varchar2(10), who varchar2(10) ) ; declare p_id number := 1; p_action varchar2(10) := 'Insert'; p_who varchar2(9) := 'Session 1'; -- procedure update_t1(p_id number, p_action varchar2, p_who varchar2) is begin update t1 set action = p_action, who = p_who where id = p_id; end; begin -- try to insert or update row for PK p_id merge into t1 d using ( select p_id id, p_action action, p_who who from dual ) s on (d.id = s.id) when matched then update set d.action = 'Update', d.who = s.who when not matched then insert values (s.id, s.action, s.who) ; exception when dup_val_on_index then -- insert is no option, update when lock is released update_t1(p_id, 'Update', p_who); end; / drop table t1 purge ;
Scenario (two sessions trying to insert/updated updated for id 1):
session 1 inserts ("1" "insert" "Session 1") and the data is not visible to the session 2
session 2 inserts same id but crashes because of the locking session 1
validation of the session 1
session 2 insert fails but who manages updating instead
session 2 commits, values for the id 1 is now ('1' 'Update' "Session 2")
-
Pass an array of bytes to the oracle stored procedure
I have a problem with moving from byte array in Oracle stored procedure as an input parameter by using odp.net.
Here is the signature of the stored procedure:
SOMEPROCEDURE(session IN NUMBER, data IN RAW)
Here is c# code, which calls the procedure:
var cmd = new OracleCommand("SOME_PROCEDURE", _connection);
cmd.CommandType = CommandType.StoredProcedure;
var bt = new byte[]{1,68,0,83,128,1};
OracleParameter sessionId = new OracleParameter("dbSessionId", OracleDbType.Decimal, new OracleDecimal(_dbSessionId), ParameterDirection.Input);
OracleParameter data = new OracleParameter("statusData", OracleDbType.Raw, new OracleBinary(bt), ParameterDirection.Input);
cmd.Parameters.Add(sessionId);
cmd.Parameters.Add(data);
cmd.ExecuteNonQuery();
This code does not (stored procedure throws exception, which cannot receive), because in byte array hadou number 128!, if I display 128 on another number, minus 128, it works great!
What should I do?
After some tests I found the solution. Initially, you cannot switch to the array of bytes via the odp.net stored procedure, if the table contains 127 large values.
Yes, solution: 1. create the wrapper procedure
procedure SOME_PROCEDURE_WRAPPER (p_session_id in number, p_data in varchar2)
is v_data raw(1024);
rawdata raw(1024);
rawlen number;
hex varchar2(32760);
i number;
begin
rawlen := length(p_data);
i := 1;
while i <= rawlen-1
loop
hex := substrb(p_data,i,2);
rawdata := rawdata || HEXTORAW(hex);
i := i + 2; end loop;
SOME_PROCEDURE(p_session_id , rawdata);
end;
2 then need to modify the code c# in this way:
var cmd = new OracleCommand("SOME_PROCEDURE_WRAPPER", _connection);
cmd.CommandType = CommandType.StoredProcedure;
string @string = statusData.ToHexString();
OracleParameter sessionId = new OracleParameter("dbSessionId", OracleDbType.Decimal, new OracleDecimal(_dbSessionId), ParameterDirection.Input);
OracleParameter data = new OracleParameter("statusData", OracleDbType.Varchar2,@string.Length, new OracleString(@string), ParameterDirection.Input);
cmd.Parameters.Add(sessionId);
cmd.Parameters.Add(data);
cmd.ExecuteNonQuery();
where
public static string ToHexString(this byte[] bytes)
{
if(bytes == null || bytes.Length == null)
return string.Empty;
StringBuilder hexStringBuilder = new StringBuilder();
foreach (byte @byte in bytes)
{
hexStringBuilder.Append(@byte.ToString("X2"));
}
return hexStringBuilder.ToString();
}
-
SSL mutual authentication using the Oracle stored procedure
Hello
DB version:
Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
Is possible to perform mutual authentication SSL uses the Oracle stored procedure?
I read articles and forums saying that it is not a good approach to call the Web service using the Oracle procedure (and I don't know if it's even possible authentication using procs). But I would like to know if it's possible and how.
In other is words there a way to incorporate the client certificate information into a procedure that calls a Web service.
I read the articles to do it in JAVA or .net. But please advice how we can achieve using Oracle procedures.
Thank you.934451 wrote:
Is possible to perform mutual authentication SSL uses the Oracle stored procedure?
To learn more. SSL what for?
Oracle PL/SQL only supports client standard TCP sockets. However, interface for HTTP, Oracle PL/SQL also supports HTTPS - which requires the certificates of authentication of the server to be stored in a portfolio of Oracle web and used during the transmission via HTTPS. See the code example {message identifier: = 1925297} for more details.
I read articles and forums saying that it is not a good approach to call the Web service using the Oracle procedure (and I don't know if it's even possible authentication using procs).
Forums and articles written by idiots. For idiots.
And no, I'm not to embellish my response to this pitch that you met. It is false. It is written by ignorant people who don't know ANYTHING about the use of Oracle and PL/SQL. And feel free to forward my response to these idiots. They find me here if they want to argue...
As an example of how to call a web service, see {message identifier: = 10158148} and {message: id = 10448611}.
-
Need to query to find stored procedures that takes great execution time
Hi all
I use the oracle version below:
Oracle Database 11 g Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE Production 11.2.0.3.0
AMT for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
is it possible to find the name of stored procedure that take too long to run, I need those optimized all SPs.
Is there a query as top queries that are used to find queries albums that have great time for execution...
or y at - it another way to find the names of MS. I try with AWR report but showing only used the names of MS.
Thank you
No, it not there no such request as far as I know.
or y at - it another way to find the names of MS.
Just listen to complaints from the user...
-
Use the utilities from the Oracle stored procedure
Hi all
I use Oracle Import to load the data from .dmp file to Oracle table.
Test/test leader IMP = Data .dmp fromuser = user1 touser = test tables = emp
But my requirement is to create a stored procedure that will import data into the table and identify the number of loaded records and how impossible to import.
Can I keep inside the procedure import statement?
Thank you.No, not possible.
IMP is an exe like sql more who can evoke to the command prompt.
If you need all the actions on the imported... table export for example/test table, and then go further.
Maybe you are looking for
-
Tecra S1 starts correctly but does not work properly and beeps from the BIOS error
Toshiba S1 began to regularly plant after a certain period of use. Sometimes: BIOS error beeps: short-short-long.Sometimes: Blue screen of reduced resolution or screen size reduced.Sometimes: Just freezes (frozen) and must be turned off manually. Tos
-
AppleScript to control the Apple TV?
I thought I could do something like: say application "iTunes." say AirPlay device "Apple TV 4th gen. pause end say end say .. .but apparently that doesn't work. The script runs without error, but nothing happens on the Apple TV. Is there another way
-
Bluetooth not working not not probook 6560 b
I have a HP ProBook 6560 problem b. Product number - XU052UT #ABA, who is having a problem with Bluetooth. It seems that theunit comes with Bluetooth, I made sure that the Bluetooth feature isrunning, but I can't do anything with Bluetooth.
-
Some programs continue to save on & on even if I did not register, how can I stop this?
I had this problem with Media Center in Vista Home Premium for well over a year. Once I recorded a show, I find that it is set to record again and again and again once without putting myself to save. It's cluttering my hard drive and become a real pa
-
I have a printerHP5510 wireless). When I go to print a document, need me a "save document area. How can I get it to print?