I have written a small proc as below:
PROCEDURE write_ToPipe ( i_key1 VARCHAR2,
i_value1 VARCHAR2,
i_key2 VARCHAR2,
i_value2 VARCHAR2,
i_key3 VARCHAR2,
i_value3 VARCHAR2,
i_key4 VARCHAR2,
i_value4 VARCHAR2,
i_key5 VARCHAR2,
i_value5 VARCHAR2 )
IS
result INTEGER;
buffer_overflow EXCEPTION;
PRAGMA EXCEPTION_INIT(buffer_overflow, -06558);
BEGIN
-- Packing the key value paires to the local buffer
dbms_pipe.pack_message(i_key1);
dbms_pipe.pack_message(i_value1);
dbms_pipe.pack_message(i_key2);
dbms_pipe.pack_message(i_value2);
dbms_pipe.pack_message(i_key3);
dbms_pipe.pack_message(i_value3);
dbms_pipe.pack_message(i_key4);
dbms_pipe.pack_message(i_value4);
dbms_pipe.pack_message(i_key5);
dbms_pipe.pack_message(i_value5);
-- sending the message to the pipe
result := dbms_pipe.send_message(pipename => 'DB_PIPE',timeout => 5);
EXCEPTION
WHEN buffer_overflow THEN
-- If the buffer overflow excetion reset the local buffer and pack the messages again
dbms_pipe.reset_buffer;
dbms_pipe.pack_message(i_key1);
dbms_pipe.pack_message(i_value1);
dbms_pipe.pack_message(i_key2);
dbms_pipe.pack_message(i_value2);
dbms_pipe.pack_message(i_key3);
dbms_pipe.pack_message(i_value3);
dbms_pipe.pack_message(i_key4);
dbms_pipe.pack_message(i_value4);
dbms_pipe.pack_message(i_key5);
dbms_pipe.pack_message(i_value5);
-- sending the message to the pipe
result := dbms_pipe.send_message(pipename => 'DB_PIPE',timeout => 5);
END write_ToPipe;
I call this proc from others procs (as below).
proc A
begin
write_ToPipe( 'TEST1','TEST2', 'TEST3','TEST4','TEST5','TEST6','TEST7','TEST8','TEST9','TEST10',);
proc B;
end
proc b
begin
write_ToPipe( 'SOMETEST1','SOMETEST2', 'SOMETEST3','SOMETEST4','SOMETEST5','SOMETEST6',NULL,NULL,NULL,nULL);
end
there is another proc I have written to unpack the msgs and write into the flat file (not shown here)
The issue is content from proc A is getting generated into the flat file but not from proc B
After debugging I found that from proc B the write_ToPipe is called but the control comes out without throwing any exception after the following line.
dbms_pipe.pack_message(i_key1);
Can you please help to solve this?
I am using Oracle 10gR2.
Thanks and Regards,
Chandra
This could be the problem with Oracle 10g. Please check with Oracle support about this.
You may also try the same program in 11g or 12c
When I try to debug a package, which has XMLTYPE as a input data i get a access violation error.
Access violation at address 00409664 in module 'Toad.exe'. Read of address 0000901B
The versions are listed below:
Oracle 11g Enterprise Edition Release 11.2.0.4.0
Oracle Client : 11.2.0.1.0
Toad : 11.6.1.6
The package I created is given below:
/**************************************************/
CREATE OR REPLACE PACKAGE SA.Cust_Orders AS
PROCEDURE save_order
(p_data IN XMLTYPE
, p_return_code OUT NUMBER
, p_status_msg OUT VARCHAR2);
END Cust_Orders;
CREATE OR REPLACE PACKAGE BODY SA.Cust_Orders AS
PROCEDURE save_order
(p_data IN XMLTYPE
, p_return_code OUT NUMBER
, p_status_msg OUT VARCHAR2) IS
BEGIN
p_return_code := 0;
p_status_msg := 'Data has been successfully saved.';
END save_order;
END Cust_Orders;
/**************************************************/
If I remove the "p_data" from the parameters I am able to debug.
I have an Oracle Stored Procedure that has a return cursor that I would like to access using EF 5. I have read multiple question from the site but still can not get it to work.
This is my oracle stored procedure:
CREATE OR REPLACE PROCEDURE GETINFO
(
"StoreId" IN varchar2 , OUT_RESULT OUT SYS_REFCURSOR
)
IS
sqlstmt VARCHAR2(2000);
BEGIN
sqlstmt := 'SELECT v."StoreId", v."ProductCategory" "Product", v."ProductId"
FROM SUPERMARKET v WHERE v."StoreId"='||"StoreId";
OPEN Out_Result FOR sqlStmt;
END GETINFO;
According to Oracle documentation, to access SYS_REFCURSOR, I have to explicitly declare it in my App.config, which I did:
<oracle.dataaccess.client>
<settings>
<oracle.manageddataaccess.client>
<version number="*">
<StoredProcedure schema="MYSCHEMA" name="GETINFO">
<refCursor name="OUT_RESULT">
<bindInfo mode="Output" />
<metadata columnOrdinal="0" columnName="StoreId" providerType="NUMBER" />
<metadata columnOrdinal="1" columnName="Product" providerType="Varchar2" />
<metadata columnOrdinal="2" columnName="ProductId" providerType="Varchar2" />
</refCursor>
</StoredProcedure>
</version>
</oracle.manageddataaccess.client>
</settings>
</oracle.dataaccess.client>
There may be other pieces hidden from Oracle documentation regarding meta data that I may have to include in the App.Config. As a result, I am still not able to access my specific SYS_REFCURSOR because when I clicked on Get Column Information, I got nothing and there was nothing in the complex combo box. According to Oracle, I should have to structure of the SYS_REFCURSOR to refer to.
My Entity Framework is 5.0, I use VS 2012.
What else do I need to include in the meta data?
My underlying SUPERMARKET table structure is:
Name Null Type
--------------- ---- ------------
StoreId NUMBER
ProductCategory VARCHAR2(20)
ProductId VARCHAR2(20)
I am having difficulty with writing my stored procedure within a package. Below is my stored procedure that compiles fine outside of the package, but I believe needs to be written differently within the package body. I admit this is my first time using a package...
create or replace PROCEDURE SP_COMMENT(P_MEMBER_ID IN VARCHAR2, P_MEMBER_LASTNAME IN
VARCHAR2, P_MEMBER_FIRSTNAME IN VARCHAR2, P_MEMBER_STARTDATE IN DATE,
P_MEMBER_ENDDATE IN DATE, P_PRODUCT_CAT_CODE IN VARCHAR2, P_COMMENT IN VARCHAR2,
COMMENT_CURSOR out sys_refcursor)
AUTHID CURRENT_USER
IS
BEGIN
EXECUTE IMMEDIATE
'INSERT INTO TEST
(
MEMBER_ID,
MEMBER_LASTNAME,
MEMBER_FIRSTNAME,
MEMBER_STARTDATE,
MEMBER_ENDDATE,
PRODUCT_CAT_CODE,
COMMENTS
)
VALUES
(
p_member_id,
p_member_lastname,
p_member_firstname,
p_member_startdate,
p_member_enddate,
p_product_cat_code,
p_comment)';
commit;
open COMMENT_CURSOR for select * from sconti.TEST;
END;
Below is the package that I started, and which is not working:
CREATE OR REPLACE
PACKAGE COMMENT_TEST IS
PROCEDURE SP_COMMENT(P_MEMBER_ID IN VARCHAR2, P_MEMBER_LASTNAME IN VARCHAR2,
P_MEMBER_FIRSTNAME IN VARCHAR2, P_MEMBER_STARTDATE IN DATE,
P_MEMBER_ENDDATE IN DATE, P_PRODUCT_CAT_CODE IN VARCHAR2, P_COMMENT IN VARCHAR2,
COMMENT_CURSOR out sys_refcursor) IS
BEGIN
EXECUTE IMMEDIATE
'INSERT INTO TEST
(
MEMBER_ID,
MEMBER_LASTNAME,
MEMBER_FIRSTNAME,
MEMBER_STARTDATE,
MEMBER_ENDDATE,
PRODUCT_CAT_CODE,
COMMENTS
)
VALUES
(
p_member_id,
p_member_lastname,
p_member_firstname,
p_member_startdate,
p_member_enddate,
p_product_cat_code,
p_comment)';
commit;
open COMMENT_CURSOR for select * from sconti.TEST;
END;
END COMMENT_TEST;
I look forward to any response to assist me....thanks!
I can't say for certain (because you haven't shared the error you're getting), but most basic error is a lack of understanding of the specification/body.
You've put the code into the package specification, rather than the body. The specification should just have the procedure declarations (i.e. no begin and end), where as the body has the full content of the procedure.
While it won't affect compilation, there is another problem: the SQL inside the string can't access the parameters supplied to the procedure. If you must use dynamic SQL (and there's absolutely no reason to in this case), then you need a using clause to bind the variable into the dynamic statement. In addition, making the SQL static will allow the SQL statement to be validated at compile-time, which has obvious advantages.
A revised packaged (specification and body) is below.
CREATE OR REPLACE PACKAGE comment_test IS
PROCEDURE sp_comment (p_member_id IN VARCHAR2,
p_member_lastname IN VARCHAR2,
p_member_firstname IN VARCHAR2,
p_member_startdate IN DATE,
p_member_enddate IN DATE,
p_product_cat_code IN VARCHAR2,
p_comment IN VARCHAR2,
comment_cursor OUT SYS_REFCURSOR);
END comment_test;
/
CREATE OR REPLACE PACKAGE BODY comment_test IS
PROCEDURE sp_comment (p_member_id IN VARCHAR2,
p_member_lastname IN VARCHAR2,
p_member_firstname IN VARCHAR2,
p_member_startdate IN DATE,
p_member_enddate IN DATE,
p_product_cat_code IN VARCHAR2,
p_comment IN VARCHAR2,
comment_cursor OUT SYS_REFCURSOR) IS
BEGIN
INSERT INTO test (member_id,
member_lastname,
member_firstname,
member_startdate,
member_enddate,
product_cat_code,
comments)
VALUES (p_member_id,
p_member_lastname,
p_member_firstname,
p_member_startdate,
p_member_enddate,
p_product_cat_code,
p_comment);
COMMIT;
OPEN comment_cursor FOR SELECT * FROM sconti.test;
END;
END comment_test;
/
I have one store procedure which has 3 input parameters and one out parameter named
'TEST(name1 IN VARCHAR2, name2 IN VARCHAR2, name3 IN VARCHAR2, result OUT VARCHAR2)'
How can i call this stored procedure using Hibernate Criteria API. My configuration as follows:
Hibernate 3.x, and Oracle.
The Criteria API does some fancy stuff but still basically just assembles and executes SQL queries.
Well, we can't use procedures in SQL, only functions. So what you need to do is re-write your procedure so it has a function's signature instead. Something like:
create or replace function test
(name1 IN VARCHAR2, name2 IN VARCHAR2, name3 IN VARCHAR2)
return varchar2
is
result varchar2(30); -- or whatever length it needs
begin
-- do your stuff here, populating RESULT as before.
return result;
end;