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.

Similar Messages

  • URGENT!!! a way to find out if Oracle stored procedures have OUT parameters

    I'm having problemes properly creating a string for the prepareCall().
    so that i can call up a stored procedure in oracle.
    the problem is that some stored procedures have OUT parameters that I have to register, and some stored procedures don't.
    how can i find out if a stored procedure has an OUT parameter or not?
    So that i can format a string with one less ? for statements that don't,
    and one more ? for statements that do have an OUT parameter.
    is there such a method as boolean OUTparameterExist();
    or i'll take any suggestions.

    any other solutions?That was the solution. You don't need to execute any sql statement to get Database Meta Data. You just need a connection, which you use to get the DatabaseMetaData instance
    DatabaseMetaData dbmd = connection.getMetaData();then invoke any of the (numerous) methods to get the info you require
    ResultSet rs = dbmd.getProcedureColumns("mydb","myschema","myproc",null);
    while(rs.next()) {
      String name = rs.getString("COLUMN_NAME");
      if (rs.getShort("COLUMN_TYPE")==DatabaseMetaData.procedureColumnOut) {
        // column is an OUT parameter
    }Dave

  • 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 Rasmus

    Hi 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

  • 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;
    /

  • Stored Procedure VARCHAR2 Out Parameters NULL.

    Hi,
    I'm having a problem. I'm calling a stored procedure with 2 number out parametes and 2 varchar2 out parameters. The number out parameters have values, but the varchar2 out parameters seem to be null after a call to the procedure. I'm using VC++ 6.0 and Provider 9.2.0.2
    Naveen

    Did you specify the size for OUT Varchar2 parameters? Note that you need to specify the size for variable sized data types but not for fixed sized data types.

  • Executing procedures with OUT parameters using Named notation

    I have a procedure with two out parameters (p_errortext and p_returncode) and i want to execute this proc in SQL*plus using named notation(using association operator ' => '). For position based execution i usually declare variables to hold the OUT parameter's value. But how can i do this while executing using named notation (using => )
    begin
         packagename.generate_ref_record(p_userid  => 'THELMA',
                                      p_ref_code       => '9A',
                                      p_item_id    => '9990000011163',
                                      p_shipno     => '0PH',
                                      p_errortext  =>  ??
                                      p_returncode =>  ??);
    end;

    SQL>variable x varchar2(30);
    SQL>variable y varchar2(30);
    SQL>exec packagename.generate_ref_record(p_userid  => 'THELMA',     
                                          p_ref_code       => '9A',       
                                          p_item_id    => '9990000011163',     
                                          p_shipno     => '0PH',     
                                          p_errortext  =>  :x        
                                          p_returncode =>  :y);

  • How to execute this procedure(having out parameters)

    PROCEDURE emp_cursor (
    v_deptno IN VARCHAR2,
    v_doj OUT DATE,
    v_empno OUT NUMBER,
    v_sal OUT NUMBER
    );

    Hi,
    812809 wrote:
    PROCEDURE emp_cursor (
    v_deptno IN VARCHAR2,
    v_doj OUT DATE,
    v_empno OUT NUMBER,
    v_sal OUT NUMBER
    emp_cursor ( expr_1
               , var_2
               , var_3
               , var_4
               );Where var_2, var_3 and var_4 are variables with the appropriate data types. You must pass variables for the OUT parameters.
    Expr_1 can can a variable, a literal, or any other kind of expression that evaluates to a VARCHAR2.
    I hope this answers your question.
    If not, post a little a simple test script (with as much of the coding as you know how to do) so that people can re-create the problem and test their ideas. Post the results you want from that code. Explain how you get those results.
    Always say which version of Oracle you're using.

  • Procedure with OUT Parameters - Creating A Report

    I have the following procedure that is used in our internal (non-APEX) apps:
    PROCEDURE SelIssueActivityPublic (
                                                p_results           OUT     SYS_REFCURSOR,
                                                p_IssueID                    IN     ems.issue.issue_id%TYPE,
                                                p_TransactionID         OUT VARCHAR2
                 ) The body of the procedure does a bunch of processing, and inserts data into a staging table. The cursor OUT parameter then returns a SELECT statement from the staging table. Since it's possible for this procedure to be hit multiple times (multiple users), the transaction ID is used to match the data in the staging table to the correct request. The procedure then deletes the data from the staging table. (I'll post it if necessary, but it's quite long, and since it's used in other applications successfully, I don't believe it's relevant to my issue.)
    I have been asked to create an APEX report of the data generated by the procedure. I've never used a procedure with an OUT parameter to set up a report. I was hoping to assign the transaction ID to a hidden variable on page load, and then using it to poplulate the report. I'm not interested in the cursor OUT parameter, I've written my own SELECT statement to grab data from the staging table.
    I tried to create a page computation that did this - item :H_P19_TRANSID, Before Header, computation = EMS.EMS_READER.SelIssueActivityPublic(:H_P19_CURSOR, 454551, :H_P19_TRANSID) [454551 is a test issue id], but I get the following error: ORA-06550: line 1, column 43: PLS-00222: no function with name 'SELISSUEACTIVITYPUBLIC' exists in this scope ORA-06550: line 1, column 7: PL/SQL: Statement ignored flowComp=H_P19_TRANSID
    Error ERR-1030 Error executing computation expression. It seems to be thinking that SelIssueActivityPublic is a function, and I'm not sure why.
    Basically I need to know how to use this existing procedure to set up my report. Once I can get the transaction ID into a page item, I'll be set.

    I never got a chance to finish this report, as I was shuffled to something else with a higher priority. Now that I'm coming back to it, I still have a few issues.
    I created a new function that does all the processing (inserting into the staging table etc.), and returns the transaction id. I then tried to set up a page computation on a hidden item to run this function and store the transaction id.
    In the computation, if I put
    reader.SelIssueActivityPubnocursor(:H_P19_ISSUEID); as the computation, I get ORA-06503: PL/SQL: Function returned without value flowComp=H_P19_TRANSACTIONID as an error. If I put return return reader.SelIssueActivityPubnocursor(:H_P19_ISSUEID); as the computation, I get ORA-06550: line 1, column 50: PLS-00103: Encountered the symbol "EMS" when expecting one of the following: . ( * @ % & = - + ; < / > at in is mod remainder not rem <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol "." was substituted for "EMS" to continue. flowComp=H_P19_TRANSACTIONID as the error. Can someone tell me what's going wrong?

  • Is there possibility use UCS2 in procedures with out parameters?

    I am trying to use UCS2 character set in my SQL strings. Everything works out nice and smoothly if I am using procedures which require only input parameters (like those which insert data in db).
    But when I try to use procedure containing one output or input/output type parameter, all parameters are shortened by one character (2 bytes) after call. Length of data is ok, but one extra null is set where last character should be. Other characters are like they should be.
    I am using Oracle version 8.1.7 in NT.
    Fist I bind my variables with OCIBindByName and then set OCI_UCS2ID with OCIAttrSet.
    ub2 csid = OCI_UCS2ID;
    m_OCIStatus = OCIAttrSet(
    (dvoid *)handle,
    (ub4) OCI_HTYPE_BIND, (dvoid *) &csid,
    (ub4) 0, (ub4)OCI_ATTR_CHARSET_ID, m_errHndl);
    Am I missing something important or what is wrong?
    Regards
    Mika

    There is no example program. There is extensive help on how to do this. Here's the basics.
    1) There are two ways to define user error codes in LV6.1. If you are using LV6.0 or earlier, only one method is possible.
    2) The 6.0 method involves wiring arrays of error codes and arrays of error code strings to the General Error Handler.vi. These codes will be used to explain any error code which is undefined in LV's internal error code database. Error codes reserved for users which are guaranteed not to be used by NI are from 5000 to 9999.
    3) The 6.1 method allows you to create a specially formatted error code file on disk that will be merged with the LV error code database each time LabVIEW launches. For help on this, go to LV's online help, and in t
    he Index tab, type
    "user-defined error codes, in text files"
    (without the quote marks)
    4) If you want to set an error into the error cluster, use the General Error Handler.vi again. Wire your error code value to the Error Code terminal (the leftmost-topmost corner terminal). Wire the name of your VI to the Error Source terminal, and wire "No Dialog" to the Type of Dialog terminal (left-side, near the bottom). The error code cluster that comes out of this VI will either be the error in (if one was set) or a new error code cluster with your error and the status bit set to TRUE.
    5) The attached demo is written in LV6.0.
    Attachments:
    Error_Demo.vi ‏37 KB

  • 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">

  • 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>

  • Calling a Stored Procedure with output parameters from Query Templates

    This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
    We encountered a problem while calling a stored procedure from MII Query Template as follows-
    1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
    a) Input1 - CLOB
    b) Input2 - CLOB
    c) Input3 - CLOB
    d) Output1 - CLOB
    e) Output2 - CLOB
    f) Output3 - Varchar2
    2. There are two ways to get the output back.
    a) Using a Stored Procedure by declaring necessary OUT parameters.
    b) Using a Function which returns a single value.
    3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
    corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
    4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
    5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
    characters)
    6. So the method 2-a is ruled out.
    7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
    Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
    Thanks in Advance.
    Rajesh

    Rajesh,
    please check if this following proposal could serve you.
    Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
    Here is an example how this could be defined.
    Package:
    type return_cur IS ref CURSOR;
    Procedure:
    PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
    OPEN myReturnCur FOR SELECT val1, val2, val3  FROM dual;
    Query:
    DECLARE
      MYRETURNCUR myPackage.return_cur;
    BEGIN
      myPackage.myProc(
        MYRETURNCUR => ?
    END;
    Good luck.
    Michael

  • Oracle Stored Procedure with out parameter

    Good morning,
    Is it possible to use an Oracle stored procedure with out parameters in MII ?
    If yes, what is the manipulation to see the values of parameters Out?
    Thank you

    Michael,
    This is the  MII query template  :
    DECLARE
    STRCOMPTERENDU NVARCHAR2(200);
    BEGIN
    STRCOMPTERENDU := NULL;
    XMII.SP_VALIDATEPROCESSORDERSLIST2 ( STRCOMPTERENDU => [Param.1]  );
    COMMIT;
    END;
    and the stocked procedure code
    CREATE OR REPLACE PROCEDURE XMII.SP_ValidateProcessOrdersList2(strCompteRendu OUT nVarchar2) IS
    tmpVar NUMBER;
    debugmode INT;
    strClauseSql varchar(2048);
    strListPOactif varchar(1024);
    dtmTimeStamp DATE;
       NAME:       SP_ValidateProcessOrdersList
       PURPOSE:   
       REVISIONS:
       Ver        Date        Author           Description
       1.0        18/06/2008          1. Created this procedure.
       NOTES:
       Automatically available Auto Replace Keywords:
          Object Name:     SP_ValidateProcessOrdersList
          Sysdate:         18/06/2008
          Date and Time:   18/06/2008, 18:45:32, and 18/06/2008 18:45:32
          Username:         (set in TOAD Options, Procedure Editor)
          Table Name:       (set in the "New PL/SQL Object" dialog)
    BEGIN
       tmpVar := 0;
       debugmode := 0;
       -- lecture date systeme pour time stamp
       select sysdate  into dtmTimeStamp from dual;
       if debugmode = 1 then
        DBMS_OUTPUT.put_line('SP_ValidateProcessOrdersList');
       end if;
       -- insertion du bloc dans le log
       insert into LOG_ORDER
        (DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
       values
       (dtmTimeStamp,'SP_ValidateProcessOrdersList',ID_LOG_ORDER.nextval);
       Commit;
        if debugmode = 1 then
        DBMS_OUTPUT.put_line('insertion LOG OK');
       end if;
    strCompteRendu := '0123456-896;0123456-897';
    commit; 
       EXCEPTION
         WHEN NO_DATA_FOUND THEN
           NULL;
         WHEN OTHERS THEN
         ROLLBACK;
         -- insertion du bloc dans le log
       insert into LOG_ORDER
        (DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
       values
       (dtmTimeStamp,' ',ID_LOG_ORDER.nextval);
       COMMIT;
           -- Consider logging the error and then re-raise
           RAISE;
    END SP_ValidateProcessOrdersList2;
    Thanks for your help
    Alexandre

  • How to execute the packaged procedure(having out param) in TOAD for Oracle

    Hi.
    Could you help me
    How to execute the packaged procedure having out parameters in TOAD for Oralce..
    Thanks..

    Use anonymous PL/SQL block to execute it.
    Example.
    DECLARE
      <out variable name> <out variable data type>;
    BEGIN
      <package name>.<procedure name>(<out variable name>);
    END;

  • I am facing a problem in passing multiple values as out parameters from fo

    Hi All,
    i am facing a problem in passing multiple values as out parameters from for loop.
    EX:
    i have a select statment inside a loop like.....
    PACKAGE SPEC:
    create or replace PACKAGE EMP_PKG AS
    TYPE TAB_NUM IS TABLE OF SCOTT.EMP.EMPNO%TYPE;
    TYPE TAB_NAME IS TABLE OF SCOTT.EMP.ENAME%TYPE;
    TYPE TAB_JOB IS TABLE OF SCOTT.EMP.JOB%TYPE;
    temp_table TAB_NUM;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB);
    END EMP_PKG;
    PACKAGE BODY:
    create or replace PACKAGE BODY EMP_PKG AS
    v_e_no NUMBER;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB) IS
    BEGIN
    select EMPNO bulk collect into temp_table from emp;
    for i in 1..temp_table.count loop
    v_e_no := temp_table(i);
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    end loop;
    end test;
    END EMP_PKG;
    PROBLEM FACING IS:
    I am expecting all rows returning from bellow select statment ...
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    But,while running the SP , i am getting error like
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SCOTT.EMP_PKG", line 16
    why i am not getting all values as out parameters.please provide a solution for me.
    Thanks in advance my friend.

    user9041629 wrote:
    Hi All,
    i am facing a problem in passing multiple values as out parameters from for loop.
    EX:
    i have a select statment inside a loop like.....
    PACKAGE SPEC:
    create or replace PACKAGE EMP_PKG AS
    TYPE TAB_NUM IS TABLE OF SCOTT.EMP.EMPNO%TYPE;
    TYPE TAB_NAME IS TABLE OF SCOTT.EMP.ENAME%TYPE;
    TYPE TAB_JOB IS TABLE OF SCOTT.EMP.JOB%TYPE;
    temp_table TAB_NUM;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB);
    END EMP_PKG;
    PACKAGE BODY:
    create or replace PACKAGE BODY EMP_PKG AS
    v_e_no NUMBER;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB) IS
    BEGIN
    select EMPNO bulk collect into temp_table from emp;
    for i in 1..temp_table.count loop
    v_e_no := temp_table(i);
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    end loop;
    end test;
    END EMP_PKG;
    PROBLEM FACING IS:
    I am expecting all rows returning from bellow select statment ...
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    But,while running the SP , i am getting error like
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SCOTT.EMP_PKG", line 16
    why i am not getting all values as out parameters.please provide a solution for me.
    Thanks in advance my friend.Probably not a bad thing that this isn't working for you.
    This is a horrible way to return the contents of a table.
    Are you doing this for educational purpose, or ... what is your goal here? If you just want to return a result set to a client you'd want to look in to using a REF CURSOR and not a bunch of arrays combined with horribly procedural (slow) code.

Maybe you are looking for