DII with multiple OUT parameters?
Is it possible to use DII to invoke a web service that has more that one output parameter?
My attempts are shown below but I only get a variety of different exceptions. If anyone
has a working example, then I would be most grateful for their advice. I am using
JWSDP 1.5 & Tomcat 5.0:
--- DII client ---
package testclient;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.XMLType;
import javax.xml.rpc.holders.*;
public class Test
private static String serviceuri = "urn:magenta/wsdl/p2p";
private static String servicewsdl = "http://localhost:8080/client/Client?WSDL";
private static String servicename = "clientService";
private static String serviceport ="clientPort";
private static String NS_XSD = "http://www.w3.org/2001/XMLSchema";
public static void main(String[] args)
try
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName(serviceuri, servicename));
Call call = service.createCall(new QName(serviceuri, serviceport));
call.setTargetEndpointAddress(servicewsdl);
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty("javax.xml.rpc.encodingstyle.namespace.uri", "http://schemas.xmlsoap.org/soap/encoding/");
call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
call.setOperationName(new QName(serviceuri, "getQuery"));
call.setReturnType(null);
call.addParameter("node", new QName(NS_XSD, "string"), ParameterMode.OUT);
call.addParameter("filename", new QName(NS_XSD, "string"), ParameterMode.OUT);
ArrayList argterms = new ArrayList();
argterms.add("");
argterms.add("");
Object result = call.invoke(argterms.toArray(new Object[argterms.size()]));
Map results = call.getOutputParams();
System.out.println((String)results.get("node"));
System.out.println((String)results.get("filename"));
catch (javax.xml.rpc.ServiceException se) { System.out.println("Service Exception: " + se.toString()); }
catch (java.rmi.RemoteException re) { System.out.println("Remote Exception: " + re.toString()); }
}-- Example Service --
package client;
import java.util.*;
import java.io.*;
import javax.xml.rpc.holders.*;
public class MyClient implements Client
public MyClient() {}
public void getQuery(StringHolder node, StringHolder filename) throws java.rmi.RemoteException
node.value = "n1";
filename.value = "f2";
}-- WSDL Description --
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions name="client" targetNamespace="urn:magenta/wsdl/p2p" xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="getQuery" />
<message name="getQueryResponse" >
<part name="node" type="ns1:string" xmlns:ns1="http://www.w3.org/2001/XMLSchema"/>
<part name="filename" type="ns2:string" xmlns:ns2="http://www.w3.org/2001/XMLSchema"/>
</message>
<portType name="client" >
<operation name="getQuery">
<input message="ns3:getQuery" xmlns:ns3="urn:magenta/wsdl/p2p"/>
<output message="ns4:getQueryResponse" xmlns:ns4="urn:magenta/wsdl/p2p"/>
</operation>
</portType>
<binding name="clientBindings" type="ns5:client" xmlns:ns5="urn:magenta/wsdl/p2p" >
<ns6:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" xmlns:ns6="http://schemas.xmlsoap.org/wsdl/soap/"/>
<operation name="getQuery">
<ns7:operation soapAction="" xmlns:ns7="http://schemas.xmlsoap.org/wsdl/soap/"/>
<input name="getQuery">
<ns8:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:magenta/wsdl/p2p" use="encoded" xmlns:ns8="http://schemas.xmlsoap.org/wsdl/soap/"/>
</input>
<output name="getQueryResponse">
<ns9:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:magenta/wsdl/p2p" use="encoded" xmlns:ns9="http://schemas.xmlsoap.org/wsdl/soap/"/>
</output>
</operation>
</binding>
<service name="clientService" >
<port binding="ns10:clientBindings" name="clientPort" xmlns:ns10="urn:magenta/wsdl/p2p">
<ns11:address location="http://localhost:8080/client" xmlns:ns11="http://schemas.xmlsoap.org/wsdl/soap/"/>
</port>
</service>
</definitions>--- ERROR MESSAGES ---
1) With this code, I get the following error:
Remote Exception: java.rmi.RemoteException: JAXRPCTIE01: caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: {http://www.w3.org/2001/XMLSchema}anySimpleType
This suggests a problem with the argterms.add(""); lines, so:
2) If I replace argterms.add(""); with argterms.add(null); I get:
Exception in thread "main" serialization error: java.lang.IllegalArgumentException: getSerializer requires a Java type and/or an XML type
at com.sun.xml.rpc.encoding.ObjectSerializerBase.serialize(ObjectSerializerBase.java:132)
at com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.java:637)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:83)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:79)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:482)
at testclient.Test.main(Unknown Source)
3) If I replace argterms.add(""); with argterms.add(new StringHolder("")); I get:
Exception in thread "main" serialization error: java.lang.NullPointerException
at com.sun.xml.rpc.encoding.ObjectSerializerBase.serialize(ObjectSerializerBase.java:132)
at com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.java:637)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:83)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:79)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:482)
at testclient.Test.main(Unknown Source)
4) If I remove the argterms.add(""); lines altogether (as these should not be necessary) then I get the following:
Exception in thread "main" unexpected element name: expected=filename, actual=node
at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.doDeserialize(SOAPResponseSerializer.java:350)
at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:192)
at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:155)
at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:285)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:215)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:79)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:482)
at testclient.Test.main(Unknown Source)
The final message suggests that the arguments are being apssed in the wrong order. However, if I
change the order of the call.addParameter lines then I still get the same message. At this point I
am suspecting a bug in the JWSDP? Can anyone shed some light on the situation?
Thanks,
Chris
Forgot to mention, I also tried adding parameterOrder to the WSDL to overcome problem 4, but it didn't have any effect:
<operation name="getQuery" parameterOrder="node filenmame">
Similar Messages
-
Web service with multiple out parameters
Hi Developers,
I have been playing around with som web services in the developer studio.
I can create a webservice from a normal ejb.
But i can only get one out parameter, which is the return parameter of the ejb.
I tried to make an object to use as return parameter, but then i couldn't use the method for the web service.
Can anyone tell me how to make a web service with multiple out parameters?
Br RasmusHi Developers,
I have the same question, is it possible to have multiple outgoing parameters?
When not, does SAP Netweaver knows a IN-OUT parameter? Because I found on the internet that it is possible to have a IN-OUT parameter. But that was with the BEA Weblogic 8.x.
When not, is then the only solution to return a object? With in this object all the parameters you want.
Or otherwise is there a other workaround?
Thanks in advance,
Marinus Geuze -
Database procedure with IN/OUT parameters
Hi,
I have a procedure with multiple OUT parameters,
but I do not know how to get the values of these out parameters in the calling procedure.
What I mean is I can simply get the value of a function from a calling procedure as:-
declare
val1 number;
begin
val1 := func_get_num;
end;
How can I get the values of OUT parameters of a procedure in a similar way?like
SQL> var ename_v varchar2(30);
SQL> var empno_v number;
SQL> create or replace procedure get_employee(empno out number, ename out varchar)
2 as
3 begin
4 select empno, ename into empno, ename from emp where rownum <=1;
5 end;
6 /
Procedure created.
Elapsed: 00:00:00.51
SQL> exec get_employee(:empno_v, :ename_v);
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.12
SQL> print empno_v
EMPNO_V
666
SQL> print ename_v;
ENAME_V
fdddfdf1
SQL> -
Problem with database adapter on plsql procedure with in/out parameters
running BPEL 10.1.3.1 and using the database adapter on a plsql procedure with in/out parameters I get errors
the plsql procedure:
create or replace procedure proc_with_clob_inout_parameter(
p_string in varchar2,
p_clob in out clob)
is
begin
p_clob := p_string;
end proc_with_clob_inout_parameter;
In BPEL I call this procedure. When I only assign a value to the p_string parameters (in a BPEL assign) all is well. When I also assign a value to the p_clob parameter the error occurs:
<part name="summary">
<summary>
file:/ora1/app/oracle/as101.3/bpel/domains/digitaaldossier/tmp/.bpel_janb_inout_1.0_f6908ccf864581b7265c362444e88075.tmp/twee.wsdl
[ twee_ptt::twee(InputParameters,OutputParameters) ] - WSIF JCA Execute of
operation 'twee' failed due to: Error while trying to prepare and execute
an API.
An error occurred while preparing and executing the
JANB.PROC_WITH_CLOB_PARAMETER2 API. Cause: java.sql.SQLException: Parameter
Type Conflict [Caused by: Parameter Type Conflict]
; nested exception is:
ORABPEL-11811
Error while trying to prepare and execute an API.
An error occurred while preparing and executing the
JANB.PROC_WITH_CLOB_INOUT_PARAMETER API. Cause: java.sql.SQLException: Parameter
Type Conflict [Caused by: Parameter Type Conflict]
Check to ensure that the API is defined in the database and that the
parameters match the signature of the API. Contact oracle support if error
is not fixable.
</summary>
</part>
In BPEL 10.1.2.0 this isn't a problem. I tested it against a 10.2.0.1 and a 10.2.0.2 database and in both situations I get the error with BPEL 10.1.3.1 and no error with BPEL 10.1.2.0
it appears to be a problem in the database adapter...
anyone with the same problems and/or a solution?Not of any use to you, but we had exactly the same problem on Friday when we applied AS 10.1.2.2 Patchset on top of BPEL 10.1.2.0.2.
The clob in our pl/sql proc wan't declared as in/out but for some reasons JDeveloper had created a clob on the Output Parameter type in the db partner link xsd. I removed this and it worked. This code had been untouched , and working fine, for months.
I'll be raising an SR today.
Rob J -
Query with multiple outer joins
I had a doubt with whether the following kind of query is valid with multiple outer-joins. The format of the query is something like this:-
select A.col1, B.col2
from table1 A, table2 B, table3 C where
A.col3=B.col4(+) and B.col5=C.col6(+)
This would mean the follwoing with regard to outer-joins in the query.
1) fetch records with col3 in table A matching or not matching col4 in table B
2) fetch records with col5 in table B matching or not matching col6 in table C
So, this query is valid?
I hope, my question is clear.
Please, help in solving the doubt.
regardsThis is valid and it works fine
-
Reg:execute procedure with in out parameters
hi,
what is the code to execute a procedure with in out parameters.can anyone give me an example
thanks872296 wrote:
thanks for the reply.
i am very much new to oracle database.i need this code to put in one of my informatica mapping.
so can you just elaborate what does 'karthick' mean?is it the name of the procedure.No, karthick is the value of the variable that is being passed into the procedure called "P" in karthicks example, then if that procedure changes the value inside, the variable will have that new value passed back out of the procedure to it.
PROCEDURE prc_mv (name VARCHAR2)
IS
BEGIN
dbms_mview.refresh (mv_name);
END prc_mv;
PROCEDURE refresh (response IN OUT NUMBER)
IS
BEGIN
dbms_mview.refresh('mv1','C');
dbms_mview.refresh('mv2','C');
response := 1;
EXCEPTION
WHEN OTHERS
THEN
response := 0;
END refresh;
can you give the code for this procedure.Yes.
DECLARE
v_response NUMBER;
BEGIN
refresh(v_response);
END;Though your code is awful. There's no point in having the response parameter as an IN OUT if you're not going to pass IN a value and use that in the code anywhere. In your case it only needs to be an OUT parameter because you're just passing back OUT a value. You are also masking any exceptions that happen by using a WHEN OTHERS clause.
Better code would be something like...
FUNCTION refresh (mv_name) RETURN NUMBER IS
v_response NUMBER := 0; -- default response value
e_mv_not_exist EXCEPTION; -- exception variable
PRAGMA EXCEPTION_INIT(e_mv_not_exist, -23401); -- connect exception name to internal oracle error number
BEGIN
dbms_mview.refresh(mv_name,'C');
v_response := 1;
EXCEPTION
WHEN e_mv_not_exist THEN -- handle specific expected exception
-- if the materialized view does not exist, handle it gracefully as we don't want to stop
response := 0;
END refresh;
declare
v_response NUMBER;
begin
v_response := refresh('mv1');
if v_response = 0 then
-- the materialized view did not exist
else
-- the materialized view refreshed ok
end if;
end;where your exception handler explicity checks for expected exceptions such as :
ORA-23401: materialized view "SCOTT"."FRED" does not exist... and any other exceptions that you're not expecting will be raised for you to see.
It's also better as a function because you don't need to pass in a response value, you just want to get a response value back.
There's rarely a good need to use OUT or IN OUT parameters. (there's some cases, but it's not something to consider doing as part of your regular design) -
Procedure multiple out parameters into a cursor
Hi,
I have a procedure that returns multiple out parameters. How do I combine those and return as a cursor?
Here is the procedure I use (modified for forums)
PROCEDURE SAMPLEPROCEDURE
(in_param1 IN NUMBER,
in_param2 IN VARCHAR2,
output_ONE IN VARCHAR2,
output_TWO IN VARCHAR2,
output_THREE IN VARCHAR2,
output_FOUR IN VARCHAR2,
output_FIVE IN VARCHAR2,
output_SIX IN VARCHAR2,
IS
BEGIN
output_one := 'YAH!';
SELECT count(*) into output_TWO FROM tablea WHERE tablea.columnB = in_param1;
IF (variable1 = 0) THEN
output_one := 'SOMETHING MISSING';
RETURN;
END IF;
SELECT count(*) into CHECKINGACCOUNT_COUNT from ACCOUNT WHERE TABLE = in_param1 AND ACCOUNT.TYPE = 'CHECKING';
IF (CHECKINGACCOUNT_COUNT <> 0) then
SELECT count(*) into output_THREE FROM tableB WHERE tableB.columnB = in_param1;
SELECT columnC into output_FOUR FROM tableC WHERE tableC.columnC = in_param1;
SELECT SUM(columnD) into output_FIVE FROM tableD WHERE tableD.columnD = in_param1;
if(output_FIVE >= input_param2) then
output_FIX := 'RETURN VALUE';
end if;
END IF;
end SAMPLEPROCEDURE;Should Use 'OUT' for Output parameter instead of 'IN' in your procedure, its wrong.
For fetching more than one row from procedure, use REFCURSOR.
Follow the Code:
CREATE OR REPLACE PROCEDURE proc_cursor (in_n_sal
IN
NUMBER,
ov_n_sumsal
OUT NUMBER,
ov_n_empno
OUT sys_refcursor,
ov_cr_details
OUT sys_refcursor)
AS
BEGIN
SELECT SUM (sal)
INTO ov_n_sumsal
FROM emp
WHERE sal = in_n_sal; /*here , the query returns only one row*/
open ov_n_empno for
SELECT empno
FROM emp
WHERE sal = in_n_sal;/*here the query may return more than one row , so i used refcursor for fetching the result set*/
open ov_cr_details for
SELECT SUM (sal), empno
FROM emp
WHERE sal = in_n_sal
group by empno;/*here also i used refcursor , to achieve more than one row and two more columns result set*/
END;
EXECUTION:
SQL> variable OV_N_SUMSAL number;
SQL> variable OV_N_EMPNO number;
SQL> variable OV_N_EMPNO refcursor;
SQL> variable OV_CR_DETAILS refcursor;
SQL> EXECUTE PROC_CURSOR ( 800, :OV_N_SUMSAL, :OV_N_EMPNO, :OV_CR_DETAILS );
PL/SQL procedure successfully completed.
SQL> PRINT OV_N_SUMSAL;
OV_N_SUMSAL
1600
SQL> PRINT OV_N_EMPNO;
EMPNO
1888
1239
SQL> PRINT OV_CR_DETAILS;
SUM(SAL) EMPNO
800 1888
800 1239
SQL>
I hope this one will help you. -
How to get multiple out parameters from a pl/sql stored procedure in ADF Jdeveloper 11g release2
I´m trying to call from AppModuleImpl a stored procedure from my oracle DB which receives one input parameter and returns 5 out parameters.
I´m using jdeveloper 11g release2 ADF and I have created a java bean "ProRecallPlatesBean " with the atributes and accesors and I serialize it. just like in this article http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvgen.htm#sm0297
This is my code so far:
public ProRecallPlatesBean getCallProRecallPlates(String numPlates) {
CallableStatement st = null;
try {
// 1. Define the PL/SQL block for the statement to invoke
String stmt = "begin CTS.Pk_PreIn.proRecallPlates(?,?,?,?,?,?); end;";
// 2. Create the CallableStatement for the PL/SQL block
st = getDBTransaction().createCallableStatement(stmt,0);
// 3. Register the positions and types of the OUT parameters
st.registerOutParameter(2,Types.VARCHAR);
st.registerOutParameter(3,Types.VARCHAR);
st.registerOutParameter(4,Types.VARCHAR);
st.registerOutParameter(5,Types.VARCHAR);
st.registerOutParameter(6,Types.VARCHAR);
// 4. Set the bind values of the IN parameters
st.setString(1,numPlates);
// 5. Execute the statement
st.executeUpdate();
// 6. Create a bean to hold the multiple return values
ProRecallPlatesBean result = new ProRecallPlatesBean();
// 7. Set values of properties using OUT params
result.setSpfVal(st.getString(2));
result.setTransportTypeVal(st.getString(3));
result.setTransportCompanyVal(st.getString(4));
result.setCompanyDescrVal(st.getString(5));
result.setDGAPrint(st.getString(6));
// 8. Return the result
return result;
} catch (SQLException e) {
throw new JboException(e);
} finally {
if (st != null) {
try {
// 9. Close the JDBC CallableStatement
st.close();
catch (SQLException e) {}
In Jdeveloper I went into AppModule.xml JAVA>Client Interface section and expose "getCallProRecallPlates" Then I can see "getCallProRecallPlates" in Data Controls, I drag and drop it to a JSF page, an input text component and a button are generated in order to put in there the procedure input parameter (numPlates).
I don't know if I'm on the right track.
When I click the button, the "result" variable is supposed to be filled with data from the stored procedure. I want each of those values to be displayed in Output text or input text adf components but I dont know how. Thank you very much in advance I´m a newbie and i'll appreciate your help!What version are you on?
Works fine for me on my 11g:
SQL> create or replace procedure testxml (clob_out out clob)
2 is
3 l_clob clob;
4 l_ctx dbms_xmlquery.ctxhandle;
5 begin
6 l_ctx := dbms_xmlquery.newcontext ('select * from dual');
7 l_clob := dbms_xmlquery.getxml (l_ctx);
8 clob_out := l_clob;
9 dbms_xmlquery.closecontext (l_ctx);
10 end testxml;
11 /
Procedure created.
SQL>
SQL> variable vout clob;
SQL>
SQL> exec testxml (:vout)
PL/SQL procedure successfully completed.
SQL>
SQL> print vout
VOUT
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DUMMY>X</DUMMY>
</ROW>
</ROWSET>But definitely you can optimize your proc a bit: Try
create or replace procedure testxml (clob_out in out nocopy clob)
is
l_ctx dbms_xmlquery.ctxhandle;
begin
l_ctx := dbms_xmlquery.newcontext ('select * from dual');
clob_out := dbms_xmlquery.getxml (l_ctx);
dbms_xmlquery.closecontext (l_ctx);
end testxml;
/ -
Using procedure with multiple out variables in a query
Hi,
We have a procedure that is time-consuming, which returns 4 variables as out parameters:
procedure calc_values(id in number, val1 out number, val2 out number, val3 out number, val4 out number) isThe id uniquely identifies an product in our database.
I would like to use this in a query (or view), in the form
select s.id, val1, val2, val3, val4 from something s, product_table p
where s.id = p.idI have tried the following approach, but I am kinda stuck
* define a type
* define a table of this type
* write a wrapper function that calls this procedure and returns the results as a table
* pivot the table into columns
* join this with the product table
It feels like I am on the wrong track, i am having trouble to get the id from the product table back into the wrapper function.
Is there a better approach to this? I am on oracle 10g
Thanks!
RobTe below is my interpretation of what you asked to do. I don't really know that it is what you want to do or what you should do.
CREATE TYPE prod_vals_def
AS OBJECT
(VAL1 NUMBER,
VAL2 NUMBER,
VAL3 NUMBER,
VAL4 NUMBER
create or replace
TYPE prod_vals_tab
AS TABLE OF prod_vals_def;
CREATE FUNCTION pvals (p_prod_id NUMBER)
RETURN prod_vals_tab PIPELINED
AS
TYPE ref0 IS REF CURSOR;
cur0 ref0;
out_rec prod_vals_def
:= prod_vals_def(NULL,NULL,NULL,NULL);
BEGIN
-- CASE replacing SELECT against table I'm not going to create
CASE p_prod_id
WHEN 1 THEN
out_rec.val1 := 1;
out_rec.val2 := 2;
out_rec.val3 := 3;
out_rec.val4 := 4;
WHEN 2 THEN
out_rec.val1 := 2;
out_rec.val2 := 3;
out_rec.val3 := 4;
out_rec.val4 := 5;
WHEN 3 THEN
out_rec.val1 := 3;
out_rec.val2 := 4;
out_rec.val3 := 5;
out_rec.val4 := 6;
WHEN 4 THEN
out_rec.val1 := 4;
out_rec.val2 := 5;
out_rec.val3 := 6;
out_rec.val4 := 7;
ELSE
out_rec.val1 := 0;
out_rec.val2 := 0;
out_rec.val3 := 0;
out_rec.val4 := 0;
END CASE;
PIPE ROW(out_rec);
END pvals;
WITH s_tab AS
(SELECT 1 AS prod_id FROM dual
UNION ALL
SELECT 2 AS prod_id FROM dual
UNION ALL
SELECT 3 AS prod_id FROM dual
UNION ALL
SELECT 4 AS prod_id FROM dual
SELECT s.prod_id, p.val1, p.val2, p.val3, p.val4
FROM s_tab s,
TABLE(pvals(s.prod_id)) p
PROD_ID VAL1 VAL2 VAL3 VAL4
1 1 2 3 4
2 2 3 4 5
3 3 4 5 6
4 4 5 6 7 -
Problem with IN OUT parameters whiloe calling procedure from Form 6i
Hi
Could some help please? I have the following scenario.
I am calling a stored procedure from form 6i by pressing a button on the form. Procedure has two IN OUT parameters, and I am passing these two IN OUT parameters and have declared them the way they are declared passed to the procedure. But I get an error when calling that procedure with these IN OUT parameters. the procedure works fine if parameters are IN only. The error says:
PLS:00363: Expression '1' cannot be used as an assigment target.
NO matter I pass some value or leave it blank, I get the same error message persistenetly.
Please help.
Thanksmake sure you are calling your procedure with variables as parameters,
i.e.
l_v1 := 1 ;
l_v2 := 'hello world' ;
your_proc(l_v1, l_v2)
not
your_proc(1,'hello world') -
StoredProcedureCall with IN OUT Parameters order in Stored Procedure
Refer to the Toplink documentID:Note 224269.1 - Using IN, OUT and INOUT parameters with StoreProcedureCall. This document can be download from OracleMetaLink:
http://www.oracle.com/support/metalink/index.html
I followed the sample code in this document to write a test case for one of complicated PL/SQL codes. The test case showed wrong results for IN/OUT and OUT parameters.
At the end of the document above, I found this paragraph
" Check the ordering of the arguments to make sure that they are in the following sequence:
All 'IN' parameters, All 'OUT' parameters and then all 'INOUT' parameters.
Your stored procedure must be set up the same way, since this is how values will be passed to it. This is the way in which TopLink stored procedure calls have been designed and implemented. "
The order of our PL/SQL codes is IN, IN/OUT and OUT. We are not allowed to change our PL/SQL codes because they are currently used in production environment. We do not want to create another versions of PL/SQL codes to comply with IN, OUT, IN/OUT parameter order mentioned above.
Do you have any work around solution?
Dennis Nguyen
LA County Sheriff ITI tried a simple example using named parameters and it worked in 9.0.4:
CREATE OR REPLACE PROCEDURE
"TEST_904"."STOREDPROCEDURE_INOUT_OUT_IN" (
P_INOUT IN OUT NUMBER,
P_OUT OUT NUMBER,
P_IN NUMBER) AS
BEGIN
P_OUT := P_INOUT;
P_INOUT := P_IN;
END;
public void storedProcedureOutInoutInTest() {
System.out.println("storedProcedureOutInoutInTest");
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("STOREDPROCEDURE_INOUT_OUT_IN");
call.addNamedArgument("P_IN");
call.addNamedOutputArgument("P_OUT", "P_OUT", Integer.class);
call.addNamedInOutputArgument("P_INOUT", "P_INOUT", "P_INOUT", Integer.class);
call.setUsesBinding(true);
DataReadQuery query = new DataReadQuery();
query.setCall(call);
query.addArgument("P_IN");
query.addArgument("P_INOUT");
Vector args = new Vector(2);
args.add(new Integer(1));
args.add(new Integer(2));
Object result = session.executeQuery(query, args);
Map map = (Map)((Vector)result).firstElement();
Integer result_p_inout = (Integer)map.get("P_INOUT");
Integer result_p_out = (Integer)map.get("P_OUT");
System.out.println("P_INOUT = " + result_p_inout);
System.out.println("P_OUT = " + result_p_out);
}Result:
P_INOUT = 1
P_OUT = 2 -
I need an example of oci V7.3 to call stored procedure with IN/OUT parameters.
Hi,
I'm developing an application to access data from Oracle V7.3 using OCI. Is there a way to get the IN, OUT and IN/OUT parameters of a stored procedure from the database ? How can I execute the stored procedures dynamically, through OCI and get the data back ? Is there any sample programs ?
Any help is appreciated.
Thanks
David LinSince ODP.NET does not support Oracle Object type, you can not call this stored procedure directly.
You can write a wrapper procedure over the existing procedure accepting basic types, e.g. Varchar, Number, etc. and call your stored procedure after creating a object from the basic types. -
Calling a Procedure with IN & OUT Parameters
Hello,
I usually call my procedures using the following way
declare variable error_msg varchar2(50)
exec simple_msg('ABC,'ABC','ABC',:error_msg);
CREATE OR REPLACE PROCEDURE SIMPLE_MSG (
ID IN VARCHAR2,
URL IN VARCHAR2,
LIST IN VARCHAR2,
ERROR_MSG OUT VARCHAR2
Now my question is i am trying to call a proc which has IN OUT parameters. Can somebody guide me on how to call the proc. Thanks
CREATE OR REPLACE PROCEDURE SIMPLE_MSG (
ID IN VARCHAR2,
URL IN VARCHAR2,
LIST IN VARCHAR2,
NAME IN OUT VARCHAR,
ERROR_MSG OUT VARCHAR2Hi,
IN OUT parameters are passed just like OUT paramenters: you must pass a variable.
If you need to set the IN OUT parameter before calling the procedure, then either
(a) use a separate EXEC command:
EXEC :name := 'Original name';
EXEC simple_msg ('ABC', 'ABC', 'ABC', :name, :error_msg);or
(b) use an anonymous PL/SQL block, like this:
BEGIN
:name := 'Original name';
simple_msg ('ABC', 'ABC', 'ABC', :name, :error_msg);
END;
/The parameter can be either a bind variable (as shown above), or a local variable (that can be used only in the block). -
Calling Oracle procedure with two OUT parameters
Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
proc_Test (p_resultset=> My_cursor)
How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
Thanks in advYes its possible to use multiple parameter as OUT type in procedure.
SQL>set serveroutput on size 1000000;
SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
2 BEGIN
3 OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
4 p_num := 1;
5 END;
6 /
Procedure created.
SQL>VAR cv REFCURSOR;
SQL>VAR num NUMBER;
SQL>EXEC myproc(:cv, :num);
PL/SQL procedure successfully completed.
SQL>PRINT cv;
SAYHELLO
Hello Oracle
SQL>PRINT num;
NUM
1
SQL>
{code} -
SQLException Calling Stored Procedure with Date OUT Parameters
Hi,
I'm trying to call a stored procedure in Oracle 10.1.0.4 using JDBC driver version 10.1.0.5. Here is the Stored procedure I'm trying to call:
CREATE OR REPLACE PROCEDURE get_collector_segment_info (
cid IN eb_collector_segment_iot.collector_id%TYPE,
cnum IN eb_collector_segment_iot.collector_num%TYPE,
sct OUT NOCOPY coll_seginfo_segment_codes,
snt OUT NOCOPY coll_seginfo_segment_names,
st OUT NOCOPY coll_seginfo_statuss,
sdt OUT NOCOPY coll_seginfo_start_dates,
edt OUT NOCOPY coll_seginfo_end_dates
AS
coll_id eb_collector_segment_iot.collector_id%TYPE;
err_msg VARCHAR2 (1000);
BEGIN
-- Check if collector_id is present. If not, get the collector ID using collector Num
IF cid IS NULL
THEN
coll_id := eb_collector_segment_get_cid (cnum, err_msg);
IF err_msg IS NOT NULL
THEN
raise_application_error
(-20001,
'Error while getting Collector ID for Collector Num: '
|| cnum
|| ', Msg: '
|| err_msg
END IF;
ELSE
coll_id := cid;
END IF;
-- Return the Segments
SELECT ecs.segment_code, es.segment_name, es.status, ecs.start_date,
ecs.end_date
BULK COLLECT INTO sct, snt, st, sdt,
edt
FROM eb_collector_segment ecs, eb_segment es
WHERE ecs.collector_id = coll_id
AND ecs.segment_code = es.segment_code
AND es.status = '1';
IF SQL%ROWCOUNT = 0
THEN
raise_application_error
(-20002,
'No Segment records found for Collector ID: '
|| coll_id
END IF;
END get_collector_segment_info;
ecs.segment_code, es.segment_name and es.status are of type VARCAHR2 and ecs.start_date and ecs.end_date are of type DATE. I wrote the following code to call the above store procedure:
connection = this.datasource.getConnection();
oracleCallableStatement = (OracleCallableStatement) connection.prepareCall("begin " + STORED_PROCEDURE_NAME
+ "(?, ?, ?, ?, ?, ?, ?); end;");
oracleCallableStatement.setNull("cid", Types.VARCHAR);
oracleCallableStatement.setLong("cnum", collectorNum);
oracleCallableStatement.registerIndexTableOutParameter(3, 100, OracleTypes.VARCHAR, 100);
oracleCallableStatement.registerIndexTableOutParameter(4, 100, OracleTypes.VARCHAR, 100);
oracleCallableStatement.registerIndexTableOutParameter(5, 100, OracleTypes.VARCHAR, 100);
oracleCallableStatement.registerIndexTableOutParameter(6, 100, OracleTypes.DATE, 0);
oracleCallableStatement.registerIndexTableOutParameter(7, 100, OracleTypes.DATE, 0);
resultSet = oracleCallableStatement.executeQuery();
When I run the code, I get a "java.sql.SQLException: Invalid PL/SQL Index Table" exception on oracleCallableStatement.executeQuery(). I tried many other variations and searched on forums but nothing worked for me. Does anyone have any idea? I'm really desparate. i use JDK 1.4.2_12 and WebLogic 8.1 SP6.
Thanks,
Zhubin
Message was edited by:
zhoozhoo
Message was edited by:
zhoozhooHi Avi,
I think you are right and I was using the wrong method. With some help from our DBA the problem was resolved Here is the correct code:
connection = this.datasource.getConnection();
oracleCallableStatement = (OracleCallableStatement) connection.prepareCall("begin " + STORED_PROCEDURE_NAME
+ "(?, ?, ?, ?, ?, ?, ?); end;");
oracleCallableStatement.setNull(1, Types.VARCHAR);
oracleCallableStatement.setLong(2, collectorNum);
oracleCallableStatement.registerOutParameter(3, OracleTypes.ARRAY, "COLL_SEGINFO_SEGMENT_CODES");
oracleCallableStatement.registerOutParameter(4, OracleTypes.ARRAY, "COLL_SEGINFO_SEGMENT_NAMES");
oracleCallableStatement.registerOutParameter(5, OracleTypes.ARRAY, "COLL_SEGINFO_STATUSS");
oracleCallableStatement.registerOutParameter(6, OracleTypes.ARRAY, "COLL_SEGINFO_START_DATES");
oracleCallableStatement.registerOutParameter(7, OracleTypes.ARRAY, "COLL_SEGINFO_END_DATES");
oracleCallableStatement.execute();
String[] segmentCodes = (String[]) oracleCallableStatement.getARRAY(3).getArray();
String[] segmentNumbers = (String[]) oracleCallableStatement.getARRAY(4).getArray();
String[] segmentStatuses = (String[]) oracleCallableStatement.getARRAY(5).getArray();
Timestamp[] startDates = (Timestamp[]) oracleCallableStatement.getARRAY(6).getArray();
Timestamp[] endDates = (Timestamp[]) oracleCallableStatement.getARRAY(7).getArray();
segments = new Segment[segmentCodes.length];
for (int i = 0; i < segmentCodes.length; i++) {
System.out.println(segmentCodes[i] + ' ' + segmentNumbers[i] + ' ' + segmentStatuses[i] + ' ' + startDates[i] + ' '
+ endDates);
segments[i] = new Segment();
segments[i].setSegmentCode(segmentCodes[i]);
segments[i].setSegmentName(segmentNumbers[i]);
segments[i].setStatus(segmentStatuses[i]);
if (startDates[i] != null) {
segments[i].setStartDate(new java.util.Date(startDates[i].getTime()));
if (endDates[i] != null) {
segments[i].setEndDate(new java.util.Date(endDates[i].getTime()));
Thanks,
Zhubin
Maybe you are looking for
-
Can I change the fonts, size of a particular column in APEX using a html template report? Edited by: user6008552 on Sep 9, 2008 3:24 PM
-
Trouble compiling cldc 1.02
I'm trying to install j2me, and I downloaded midp, j2mewtk, cldc, and midp-palm. Where I'm having the most trouble currently is trying to build cldc. I'm running NT4, but I don't have cl, which the build wants to use. I do have g++. Can anyone help m
-
Connecting AppleTV via Ethernet
My Mac is plugged into my Broadband router via an Ethernet cable. If I plug an Apple TV into the router too will this allow me to stream content via the Ethernet cable? Or will it only stream content via WiFi?
-
WiFi Adapter not detected on T530
Hi there, I just purchased a refurb T530 form the Lenovo outlet and have had enormous problems with the Wifi Adapter. Machine: T530 Win 64 Pro Wifi card Realtek I know there have been many similar discussions of this issue in the past, so I can start
-
I am trying to open my emails in my cable account, but I cannot. It gives me an error: Object does not suppot this property or method. What can I do stop this error? I can see my list of emails but I can't open it. help!