Output Parameter cast problems

Wondering if anyone has seen this ...
Migrating a data access layer (based on the MS DAAB) using the ODP.NET provider. I wrote my own parameter discovery code to dynamically configure parameters at runtime - just like the SqlCommandBuilder.DeriveParameters() method does for SQL Server sprocs.
(I query the "all_arguments" view to get this data, by the way, passing the package name and procedure name.)
Here's the problem: you cannot discover the Size property for a parameter via this query. Bummer. So for VarChar2 and Char types I tried setting the Size to somethng big, like 2000.
When I retrieve the parameters after an ExecuteNonQuery statement, I am getting Type cast errors:
"Cast from type 'OracleString' to type 'String' is not valid"
Here's the weird part:
- CType(params(5).Value, Integer) 'WORKS
- CType(params(2).Value, String) 'DOESN'T WORK
- params(2).Value.ToString 'WORKS
- CType(params(2).Value, Date) 'DOESN'T WORK
What the ...? Why can't I cast a VarChar2 or Char type back to a .NET String? Why does ToString work but Ctype() not work?
I hope somebody can offer guidance, I've got a lot invested in this DAL :-)
Thanks eh
Kurt Mang
Vancouver BC

There's not really an elegant way to provide these conversions in VB. In C# OracleString uses operator overloading to provide type conversions, but this version of VB doesn't support it.
They might have implemented IConvertible on the oracle types.
Then you could write
Dim osw as new OracleString("Hello")
Dim s as String = CType(osw, IConvertible).ToString
But that's not really better than
Dim osw as new OracleString("Hello")
Dim s as String = osw.Value
The long and short of it is, OracleTypes ( and other ADO.NET provider types), are special high-performance types (usually value types), and they convert using a different idiom. By convention they are converted to the corresponding framework type using a property called .Value, and constructed from framework types using a constructor.
String s = New OracleString("Hello").Value
Converts the Unicode string "Hello" to an OracleString structure, and then back to a unicode string.
David

Similar Messages

  • Stored procedure output parameter cast problem - there was a mistake in the

    Hi
    I call to an oracle stored procedure from java and when i get the output parameter i get a classCastException.
    The output parameter is for example of typeA
    typeA is a sql object composed by a parameter of typeB and a parameter of typeC
    typeC is a sql table of typeD objects
    and typeD, typeB are objects composed by numbers, varchar2, date.....
    I know that i have all the java to sql mappings correctly done because when my typeA is an input parameter of a procedure, it works correctly.
    But when i have it as an output parameter i can�t solve the classCastException.
    This is more or less my java code to call to the procedure:
    dbConn=DriverManager.getConnection(dnsName,dnsUser,dnsPwd);
    Map map = dbConn.getTypeMap();          
    map.put("TYPEA", Class.forName("tiposOracle.inv.Inv"));               
    map.put("TYPEB", Class.forName("tiposOracle.inv.Inv_cab"));               
    map.put("TYPED", Class.forName("tiposOracle.inv.Inv_lin"));
    CallableStatement cstmt = dbConn.prepareCall("{call GENERAL.OBTENER_MENSAJE (?,?)}");
    cstmt.setBigDecimal(1, codMensaje);
    cstmt.registerOutParameter(2, OracleTypes.STRUCT, "TYPEA");
    cstmt.execute();
    Inv inv = (Inv)cstmt.getObject(2,map);       ////////Here the exception-----------------------------------------------------------------------------------------------
    The java class Inv represents the sql object typeA as this:
    public Inv_cab cab;
    public ARRAY lins;
    And the classes Inv_cab and Inv_lin typeB and typeD with dates, BigDecimals and String.
    lins is the table of Inv_lin.
    And finally, this is the exception i get:
    java.lang.ClassCastException
    at tiposOracle.inv.Inv.readSQL(Invrpt.java:29)
    at oracle.sql.STRUCT.toClass(STRUCT.java:829)
    at oracle.sql.STRUCT.toJdbc(STRUCT.java:734)
    at oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:6094)
    at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:840)
    at principal.PedirDatosMensaje.main(PedirDatosMensaje.java:103)
    Can anyone help me?
    Thanks

    Now i get this exception in cstmt.registerOutParameter(2, OracleTypes.STRUCT);java.sql.SQLException: Conflicto de tipo de par�metro: sqlType=2002
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:248)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:402)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:471)
         at principal.PedirDatosMensaje.main(PedirDatosMensaje.java:78)
    Conflicto de tipo de par�metro means: conflict of parameter type

  • Stored procedure output parameter cast problem

    Hi
    I call to an oracle stored procedure from java and when i get the output parameter i get a classCastException.
    The output parameter is for example of typeA
    typeA is a sql object composed by a parameter of typeB and a parameter of typeC
    typeB is a sql table of typeD objects
    and typeD, typeB are objects composed by numbers, varchar2, date.....
    I know that i have all the java to sql mappings correctly done because when my typeA is an input parameter of a procedure, it works correctly.
    But when i have it as an output parameter i can�t solve the classCastException.
    This is more or less my java code to call to the procedure:
    dbConn=DriverManager.getConnection(dnsName,dnsUser,dnsPwd);
    Map map = dbConn.getTypeMap();          
    map.put("TYPEA", Class.forName("tiposOracle.inv.Inv"));               
    map.put("TYPEB", Class.forName("tiposOracle.inv.Inv_cab"));               
    map.put("TYPED", Class.forName("tiposOracle.inv.Inv_lin"));
    CallableStatement cstmt = dbConn.prepareCall("{call GENERAL.OBTENER_MENSAJE (?,?)}");
    cstmt.setBigDecimal(1, codMensaje);
    cstmt.registerOutParameter(2, OracleTypes.STRUCT, "TYPEA");
    cstmt.execute();
    Inv inv = (Inv)cstmt.getObject(2,map);       ////////Here the exception-----------------------------------------------------------------------------------------------
    The java class Inv represents the sql object typeA as this:
    public Inv_cab cab;
    public ARRAY lins;
    And the classes Inv_cab and Inv_lin typeB and typeD with dates, BigDecimals and String.
    lins is the table of Inv_lin.
    And finally, this is the exception i get:
    java.lang.ClassCastException
         at tiposOracle.inv.Inv.readSQL(Invrpt.java:29)
         at oracle.sql.STRUCT.toClass(STRUCT.java:829)
         at oracle.sql.STRUCT.toJdbc(STRUCT.java:734)
         at oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:6094)
         at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:840)
         at principal.PedirDatosMensaje.main(PedirDatosMensaje.java:103)
    Can anyone help me?
    Thanks

    Now i get this exception in cstmt.registerOutParameter(2, OracleTypes.STRUCT);java.sql.SQLException: Conflicto de tipo de par�metro: sqlType=2002
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:248)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:402)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:471)
         at principal.PedirDatosMensaje.main(PedirDatosMensaje.java:78)
    Conflicto de tipo de par�metro means: conflict of parameter type

  • Output parameter rowtype problem

    Hi,
    I have this type from Oracle:
    TYPE typ_vec_com_acces_doss IS TABLE
    OF COM_ACCES_DOSS%ROWTYPE
    INDEX BY binary_integer;
    And this Stored proc
    PROCEDURE LireAccesDossier (p_cod_ret OUT NOCOPY NUMBER,
    p_msg_ret OUT NOCOPY VARCHAR2,
    p_vec_com_acces_doss OUT NOCOPY
    typ_vec_com_acces_doss, ********************This is my problem!!!!!!
    p_app_cod IN
    COM_ACCES_DOSS.APP_COD%TYPE,
    p_ado_nom_tbl IN
    COM_ACCES_DOSS.ADO_NOM_TBL%TYPE DEFAULT NULL,
    p_ado_id_doss IN
    COM_ACCES_DOSS.ADO_ID_DOSS%TYPE DEFAULT NULL,
    p_ado_no_util_acces IN
    COM_ACCES_DOSS.ADO_NO_UTIL_ACCES%TYPE DEFAULT NULL,
    p_ado_dc IN
    COM_ACCES_DOSS.ADO_DC%TYPE DEFAULT NULL,
    p_ado_des_id_doss IN
    COM_ACCES_DOSS.ADO_DES_ID_DOSS%TYPE DEFAULT NULL);
    I need to call this procedure and attempting to
    catch p_vec_com_acces_doss on output.
    How can I do this in C# or VB.NET?

    Arnold,
    I subscribe to this forum because I searched for 2 days on the Internet to see anything about the subject and didn't find anything.
    This is my last attempt to find a solution to my problem.
    I can use a SQL string in my VB.NET code to retrieve what I want but this is a simple easy way and not very a good OOP design.
    I'm a bit frustrated because I canno't find answer to this question.
    But tks to have replied

  • Problem with Output parameter  in HR function

    Hi,
    I have a function "Z" done with tx PE04, the country it's venezuela, and i define the IT table as entry and output parameter.
    When i run the payroll, ithe changes that i did by abap code in order to change one concept of the IT table doesn't appears in the log. I do this in others versions of sap and works... I working with SAP ECC 6.0.
    Thanks,
    Albio.-

    Hi,
    This function it's not of the transaction se37, it was created using the transaction pe04, there are two types of parameters entry and output for the payrolls' log.
    I have created several functions with pe04, and never this happened.
    Thanks in advance.
    Albio.-

  • How to check for null value of output parameter?

    Hi guys, I get a test procedure with 2 output parameters and do nothing:
    CREATE OR REPLACE PACKAGE BODY p_parameters_test AS
      PROCEDURE p_null_output_basetype(p1 OUT NUMBER,p2 OUT VARCHAR2)
      AS
      BEGIN
        DBMS_OUTPUT.PUT_LINE('DO NOTHING');
      END p_null_output_basetype;
    END;And I have below C# code:
    cmd.CommandText = "p_parameters_test.p_null_output_basetype";
    OracleParameter p1 = new OracleParameter("p1", OracleDbType.Decimal, System.Data.ParameterDirection.Output);
    OracleParameter p2 = new OracleParameter("p2", OracleDbType.Varchar2, System.Data.ParameterDirection.Output);
    cmd.Parameters.Add(p1);
    cmd.Parameters.Add(p2);
    try
        conn.Open();
        cmd.ExecuteNonQuery();
        if (p1.Value==null)
            Console.WriteLine("p1.Value==null");
        else if (Convert.IsDBNull(p1.Value))
            Console.WriteLine("Convert.IsDBNull(p1.Value)");
        else
            Console.WriteLine("p1 else "+p1.Value);
        if (p2.Value==null)
            Console.WriteLine("p2.Value==null");
        else if (Convert.IsDBNull(p2.Value))
            Console.WriteLine("Convert.IsDBNull(p2.Value)");
        else
            Console.WriteLine("p2 else "+p2.Value);
        Console.WriteLine("finished");
    catch......The output of it is:
    p1 else null
    p2 else null
    Does anyone have any idea why it always goes to the 'else' of the condition-branching, and how can I check if the output parameter is null?
    Thanks in advance.

    Morven... I ran into similar problems. Maybe you've found a solution of your own by now, but here's what I've learned...
    The Value property of output parameters, like p1 and p2 in your code, actually varies, according to (I think) the OracleDbType of the parameter. You've got OracleDbType.Decimal for p1 and OracleDbType.Varchar2 for p2. These look about right, since they match the parameter types in your actual stored procedure.
    After cmd.ExecuteNonQuery() executes, the respective Value properties of p1 and p2 are actually of different types. For p1, it's going to be "OracleDecimal" and for p2 it's "OracleString". Keep in miind that these are the types of the Value property of the OracleParameter objects, not the OracleParameter objects themselves.
    OracleDecimal and OracleString (and some other types like OracleDate, etc.) have an "IsNull" property you can use if you cast the Value property to its runtime type...
    if ((OracleDecimal)cmd.Parameters["p1"].Value).IsNull) { …do something… }
    else { …do something else… }
    Or maybe something like this...
    Decimal p1val = ((OracleDecimal)cmd.Parameters["p1"].Value).IsNull ? 0 : ((OracleDecimal)cmd.Parameters["AVG_SALARY"].Value).Value;
    I'll admit that expressions like this: ((OracleDecimal)cmd.Parameters["AVG_SALARY"].Value).Value look a little weird. But the "Value" of the "OracleDecimal" property is a regular .NET decimal type (System.Decimal). So, it's a "Value" of the "Value" property of the OracleParameter class.
    Even when the stored procedure returns a null, the Value property is still populated. In the case of p1, it's populated with an OracleDecimal object (actually a struct) where IsNull is true. That's why "p1.Value==null" tests false.
    From what I can see, OracleDecimal, OracleString, etc. will never be typed as DbNull, or DBNull.Value. So, that would be why Convert.IsDBNull(p1.Value)) always returns false. btw, it appears that these are Value types. That would suggest that coding something like like this, should be avoided…
    OracleString p2val = ((OracleString)cmd.Parameters["p2"].Value;
    if (p2val.IsNull) { …do something… }
    else { …do something else… }
    By assigning the value to another variable, you’d be actually creating an entire copy of the OracleString structure, which is pointless.
    I hope that helps
    Edited by: 897674 on Jan 3, 2012 10:44 AM
    Edited by: 897674 on Jan 3, 2012 10:46 AM

  • Runtime casting problems

    The following code gives me runtime casting problems:
    package edu.columbia.law.markup.test;
    import java.util.*;
    public class A {
       protected static Hashtable hash = null;
       static {
          hash = new Hashtable ();
          hash.put ("one", "value 1");
          hash.put ("two", "value 2");
       public static void main (String args []) {
           A a = new A ();
           String keys [] = a.keys ();
           for (int i = 0; i < keys.length; i++) {
               System.out.println (keys );
    public String [] keys () {
    return (String []) hash.keySet ().toArray ();
    The output on my console is:
    java.lang.ClassCastException: [Ljava.lang.Object;
            at edu.columbia.law.markup.test.A.keys(A.java:37)
            at edu.columbia.law.markup.test.A.main(A.java:29)I can not understand why is it a problem for JVM to cast?
    Any ideas?
    Thanks,
    Alex.

    return (String []) hash.keySet ().toArray ();This form of toArray returns an Object[] reference to an Object[] object. You cannot cast a reference to an Object[] object to a String[] reference for the same reason that you cannot cast a reference to a Object object to a String reference.
    You must use the alternate form of toArray instead:
    return (String []) hash.keySet ().toArray (new String[0]);This will return an Object[] reference to a String[] object, and this reference can be cast to a String[] reference.

  • REST Web Service Output Parameter not working in POST Handler

    I've created a RESTful Web Service in Oracle Apex, using a POST method as "handler".   I've setup 11 input parameters which all work fine, it is my one output parameter that does not return successfully.
    Here is detail on the Output Paramter
    Name:  returns
    Bind Variable Name:  :returns
    Access Method:  OUT
    Source Type: Response
    Parameter Type:  String
    The actual source is a call to a pl/sql package that returns a value that I set :returns equal to (eg :returns := v_result).   I've tried this with Source Type Header and still the same result, 'no output'.
    I see APEX is calling wwv_flow_api.create_restful_param to generate the parameters (for importing), is there any documentation on this procedure?
    How can I get this output parameter to return something in the response?
    The request accepts a Json payload.
    Any help greatly appreciated
    Thanks,
    James

    Solved my own problem :returns does not work needs to be returns
    Does Not Work
    Name:  returns
    Bind Variable Name:  :returns
    Access Method:  OUT
    Source Type: Response
    Parameter Type:  String
    Does Work
    Name:  returns
    Bind Variable Name:  returns
    Access Method:  OUT
    Source Type: Response
    Parameter Type:  String

  • How to retrieve Stored Procedure Output Parameter?

    Hi,
    I'm using a stored procedure with MS SQL Server. The stored procedure creates the required table entries correctly. After executing the procedure i free the resulting recordset reference and am able to retrieve the return value of the stored procedure. However,
    I am not able to retrieve the output parameters of the procedure. I am connected to the database using the MS OLE DB Provider for SQL Server. I tried using ODBC as well. Didn't work either. I know this issue has been addressed before, did anyone come up with a solution for this problem?
    Thanks in advance,
    Marco

    I can tell you what I do with LabSQL and a single output parameter. After I open the connection to the database, I execute a SQL statement that looks like this:
    declare @resultID int
    execute spInsUUTResult @SerialNumber = '999DEBUGXXX',
    @SequenceName = 'Sequence File2.seq',
    @CategoryID = 2,
    @TypeID = 1,
    @StartDateTime = '10-10-2003 13:42:45',
    @ExecutionTime = 3.5698713,
    @UUTStatus = 'Passed',
    @UserName = 'Dennis Knutson',
    @StationName = 'DENNIS-KNUTSON',
    @UUTResultID = @resultID OUTPUT
    This query result is the output parameter. I first debugged the call to the stored procedure in the SQL Server Query Analyzer and then just copied that straight into my LabVIEW code. You may be using something other than LabSQL but you should have a function t
    hat allows for raw SQL commands.

  • Help with Input/Output Parameter Size using OLE DB Provider

    I am using the OLE DB Provider for 9i in an Active Server Page to call a stored procedure in a 9i database. I pass have an input/output parameter (adVarChar with adSize=30) in which I pass a two digit number in, and expect to get a character value greater than 2 characters in return. However, when I execute the stored procedure call, it appears the value being returned in the parameter is being truncated to the size of the value I passed in (2 characters). Is there a way I can insure the parameter will return the entire length of the result regardless of the length of the input value?

    cmd.Parameters.Add("retstatus", OracleDbType.Varchar2, 200, ParameterDirection.InputOutput); It seems to me that you're trying to use an OracleParameter constructor with parameter name, parameter type, parameter SIZE, and parameter direction. But OracleParameter class does not have any such constructor. Therefore, your test tries to use another constructor incorrectly.
    OracleParameter has two constructors with four parameter ...
    public OracleParameter(string parameterName, OracleDbType type, object obj, ParameterDirection direction)
    public OracleParameter(string parameterName, OracleDbType type, int size, string srcColumn)
    ... and none of these matches your constructor. One way to solve this problem is to use appropriate constructor or OracleParameter properties.

  • Oracle VarChar for ADO Output Parameter

    I have a VB6 app on XP that uses OLE DB and ADO to access data from Oracle. I am trying to create and append and output parameter to my SQL command. The output parameter is of type VarChar in Oracle. I tried to choose adChar, adVarChar, adLongVarChar for this Output parameter type, but I keep getting "3708 Parameter object is imoproperly defined." error.
    What should be right mapping from ADO's DataTypeEnum to Oracle's VarChar???

    I'm not up on the latest, but, the last time I looked at it, we were supposed to use VARCHAR2, not VARCHAR.
    Anyhow, I use VB6 and ADO all the time ... usually with MSDAORA or ODBC, but, regardless, I use adVarChar and have never had a problem with it. You might check to make sure your Size is big enough. I usually just use 255 for Size. I haven't used an OUT parameter in a while, but you might try initialized your parameter value to String(" ", 255) or the like.
    Good luck.

  • Custom action with XML type input and output parameter.

    Hi,
    I want to develop custom action with xml type input and/or output parameter.
    Is there sample code for java side. How is the definition of input and/or output parameter and set/get methods?
    does it need special .jar file to develop custom action like this?
    Thanks.

    Cemil - yes, you can use XML data types.  Use the class
    com.sap.lhcommon.xml.XMLDataType
    for your parameter type.  Here is a snippet from a custom action we use to log XML (instead of just returning the #text node like the default logger does):
    public class XMLLogger extends ActionReflectionBase
        private String source;
        private String eventType;
        private String textMessage;
        private XMLDataType xmlMessage;
        public XMLLogger()
            log = new Logger("UserLog");
            source = DEFAULT_SOURCE;
            eventType = TYPE_INFO;
            textMessage = "";
            xmlMessage = new XMLDataType();
        public XMLDataType getXmlMessage()
            return xmlMessage;
        public void setXmlMessage(XMLDataType xmlMessage)
            this.xmlMessage = xmlMessage;
        public void Invoke(Transaction transaction, ILog ilog)
            StringBuffer sb = new StringBuffer();
            sb.append('[');
            sb.append(source);
            sb.append("] ");
            sb.append(textMessage);
            sb.append(XMLUtils.convertXmlToString(xmlMessage));
    XMLUtils is a helper class we wrote - it's just a bunch of standard Java XML boilerplate code.  The important part you need to know is XMLDataType.getDocument() will return an org.w3c.dom.Document.
    I hope that was enough information to help.
    -tim

  • Getting error while Calling Oracle Stored Procedure with output Parameter

    HI All,
    From long days i am working on this but i unable to solve it.
    Even i have studied so many forums in SAP but i didn't find the solution.
    I am calling Oracle Store procedure with 3 inputs and 1 output without cursor.
    Store Procedure:-
    CREATE OR REPLACE PROCEDURE PDS.send_rm
    IS
    proc_name           VARCHAR2(64) := 'send_rm';
    destination_system  VARCHAR2(32) := 'RAWMAT';
    xml_message         VARCHAR2(4000);
    status_code         INTEGER;
    status_message      VARCHAR2(128);
    debug_message       VARCHAR2(128);
    p_ret               INTEGER;
    BEGIN
      DBMS_OUTPUT.PUT_LINE( proc_name || ' started' );
      xml_message := '<RAW_MATERIAL>'||
                     '<BAR_CODE>10000764601</BAR_CODE>'||
                     '<MATERIAL>1101448</MATERIAL>'||
                     '<VENDOR_CODE/>'||
                     '<PRODUCTION_DATE>0000-00-00</PRODUCTION_DATE>'||
                     '<EXPIRE_DATE>0000-00-00</EXPIRE_DATE>'||
                     '<BATCH/>'||
                     '<PO_NUM/>'||
                     '<MATERIAL_DESCRIPTION>POWER SUPPLY</MATERIAL_DESCRIPTION>'||
                     '<SPEC_NAME/>'||
                     '<STOCK_CODE>BSW-JH</STOCK_CODE>'||
                     '<INSPECTION_LOT>00</INSPECTION_LOT>'||
                     '<USAGE_DECISION_CODE/>'||
                     '<MATERIAL_GROUP>031</MATERIAL_GROUP>'||
                     '</RAW_MATERIAL>';
          dbms_output.put_line('XML '||xml_message);
    --      vp_interface.load_rawmat@cnprpt1_pds(SYSDATE, destination_system,
    --                   xml_message, p_ret);
          vp_interface.load_rawmat(SYSDATE, destination_system,
                       xml_message, p_ret);
          dbms_output.put_line('Return Code '||p_ret);
          COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
        status_code := SQLCODE;
        status_message := SUBSTR(SQLERRM, 1, 64);
    --    Extract_Error_Logger(proc_name, 'LOCAL', SYSDATE, -999,
    --                         status_message, 0, debug_message);
        ROLLBACK;
    END send_rm;
    And while i am calling this Store procedure in MII, I am facing error.
    I have tried different ways but didnt solved
    In SQL Query, i kept mode as: FixedQueryOutput
    Can anyone tell me or send code for calling above store procedure
    And onemore thing, While creating store procedure in Oracle for MII. Do we need to Create output parameter as cursor or normal.  
    Thanks,
    Kind Regards,
    Praveen Reddy M

    Hi Praveen
    Our wrapper was created because we could not modify the procedure we call (it was not returning a cursor).
    CREATE OR REPLACE PROCEDURE CHECK_PUT_IN_USE
    (STRCMPNAME in varchar2,
    STRSCANLABEL in varchar2,
    RCT1 out SYS_REFCURSOR
    AS
      charDispo          Char(1);
      charStatus          Char(1);
      intCatNo          Integer;
      charCatDispo     Char(1);
      strCatQual          VarChar2(2);
      strCatDesc          VarChar2(30);
      strMsg          VarChar2(128);
    BEGIN
    qa.check_put_in_use@AR(STRCMPNAME,
                                              STRSCANLABEL,
                                              charDispo,
                                              charStatus,
                                              intCatNo,
                                              charCatDispo,
                                              strCatQual,
                                              strCatDesc,
                                              strMsg);
    OPEN RCT1
    FOR Select charDispo,charStatus,charDispo,charStatus,intCatNo,charCatDispo,strCatQual,strCatDesc,strMsg from Dual;
    END;
    Hope this helps
    Regards
    Amrik
    then with a FixedQueryWithOutput
    call mixar.qasap.wrapper_update_put_in_use('[Param.1]','[Param.2]',[Param.3],?)
    Hope this helps.

  • Associative Array with more than one field - retrieving as output parameter

    Hello,
    I'm developing an C# Application that is showing a datagrid with results from a PL/SQL procedure inside a Package.
    The .net project is in .net 4 and the DB is an oracle 10g.
    I have read the odp.net sample about the associative array. I could successfully pass as an input parameter a string[] and dealing with it inside my PL/SQL procedure.
    Now it become more complex to me because I would like to return an associative array defined like this :
    TYPE r_FinalExtract IS RECORD
    RecordmyTable myTable%ROWTYPE,
    Tel1 varchar2(25),
    Tel1Libelle varchar2(50),
    Tel2 varchar2(25),
    Tel2Libelle varchar2(50),
    Tel3 varchar2(25),
    Tel3Libelle varchar2(50),
    Tel4 varchar2(25),
    Tel4Libelle varchar2(50),
    Tel5 varchar2(25),
    Tel5Libelle varchar2(50),
    Email1 varchar2(50),
    Email1Libelle varchar2(50),
    Email2 varchar2(50),
    Email2Libelle varchar2(50)
    TYPE t_FinalExtract IS TABLE OF r_FinalExtract INDEX BY BINARY_INTEGER;
    You can guess my PL/SQL stored procedure is filling this collection.
    The spec of my procedure :
    PROCEDURE P_SELECTDATA( ptab_ListRef IN t_AssocArrayVarchar2, ptab_Result OUT t_FinalExtract );
    Unfortunately, in my .net project, I don't know how to deal with that.
    I tryed to add p_Result as an output parameter but you have to define the OracleCollectionType for that parameter and the array type is not the good one because my t_FinalExtract is not a simple array...
    I searched over the internet and the only one thread I could find is someone who was doing like me... and finally reply to his own thread 3 months later and said that he had to create CSV lines and return a table of varchar2...
    This is what I will do because I'm loosing time for finding the way to do it with my associative array, but if someone has the solution I would be glad to read it.
    Thanks in advance.

    For PL/SQL records, I would recommend using User-Defined Types (UDTs), rather than associative arrays.
    You can read more on how to use ODP.NET UDTs here:
    http://docs.oracle.com/cd/E20434_01/doc/win.112/e23174/featUDTs.htm#CJAGCAID
    Strictly speaking, ODP.NET doesn't support PL/SQL Records per se. Instead, ODP.NET supports building any generic UDT in the Oracle DB, which covers the effective functionality of a Record.
    If you want to walk through the process of taking a sample DB UDT, generating a .NET custom class, then passing an instance between DB and application, here's a tutorial that shows you how to do that:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/userdefinedtypes/userDefinedTypes.htm

  • How to call a Stored Procedure with a REF CURSOR output parameter

    I am looking forward an example that call a stored function/procedure with a REF CURSOR output parameter and get the result.
    In other words, I have a stored function/procedure that execute a SELECT statement using the OCI library and then it could get the values of each column and each row.
    I put a code snippet, it have only the main thing to call a simple stored procedure and print the name of each column of the cursor, but I couldn´t to print out the values in the table that call the stored procedure.
    I understand that the next step, it is to call a OCIStmtFetch.
    How to associate the cursor with the OCIStmtFetch?
    If you need more information, only tell me.
    I am using ANSI C with HP-UX Operative System (C for HP-UX) and Oracle 10g.
    Regards.
    Antonio Garcia
    /* callOracleSP */
    #include <stdio.h>
    #include <string.h>
    #include <oci.h>
    #include <stdlib.h>
    char* pConnectChar ="server";
    char* pUsernameChar = "user";
    char* pPasswordChar = "passwd";
    char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
    int retval;
    ub4 parmcnt=0;
    ub4 pos2=0;
    text *pcoln[20];
    ub4 namelen[20];
    char state_key[5];
    OCIStmt* pOciStatement;
    OCIStmt* pOciStatCursor;
    OCIError* pOciError;
    OCIEnv* pOciEnviron;
    OCIServer* pOciServer;
    OCISession* pOciSession;
    OCISvcCtx* pOciServiceContext;
    OCIBind* pOciBind[500];
    OCIParam* pOciParam;
    int main()
    retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
    retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
    retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
         strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
                   (unsigned char *)pConnectChar,strlen(pConnectChar));
    printf("OCILogon retval=%d\n",retval);
    retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
         OCI_NTV_SYNTAX, OCI_DEFAULT);
    printf("StmtPrepare retval=%d\n",retval);
    retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
    retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
         (sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
    printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
    retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
         (sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
    printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
    strcpy(state_key,"CA");
    retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
         (OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
    printf("StmtExecute retval=%d\n",retval);
    /* How to get the values of the cursor? */
    /* Get number of parameters of the Cursor */
    OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
         (ub4)OCI_ATTR_PARAM_COUNT, pOciError);
    printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
    for (int pos = 1; pos <= (int)parmcnt; pos++)
         OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
              (ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
         retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,
              (ub4) pos );
         OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &pcoln[pos-1],(ub4 *) &namelen[pos-1],
              (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
    for (int i = 1; i <=(int)parmcnt; i++)
    printf("Column %i\tNAME = %.*s\n",i,namelen[i-1],pcoln[i-1]);
    return 0;
    This is the script that create the table, insert records and create the stored procedure
    CREATE TABLE CITIES (
         STATE_CODE     VARCHAR2(2) NULL,
         CITY_CODE      NUMBER(15,5) NULL,
         CITY_NAME      VARCHAR2(30) NULL
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 30, 'SAN DIEGO')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 40, 'SACRAMENTO')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('FL', 10, 'MIAMI')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('FL', 20, 'ORLANDO')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('NY', 10, 'NEW YORK')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('NY', 20, 'ALBANY')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 10, 'LOS ANGELES')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('CA', 20, 'SAN FRANCISCO')
    CREATE OR REPLACE PACKAGE globalPkg AUTHID CURRENT_USER AS
    /* The following are T/SQL specific global variables. */
    TYPE RCT1 IS REF CURSOR;/*new weak cursor definition*/
    END globalPkg;
    CREATE OR REPLACE PROCEDURE SP_ADDCITY(
    P_STATE_CODE IN VARCHAR,
    P_CITY_CODE      IN NUMBER,
    P_CITY_NAME      IN VARCHAR2,
    P_RETURN IN OUT NUMBER)
    AS
    StoO_error INTEGER;
    StoO_selcnt INTEGER;
    StoO_rowcnt INTEGER;
    StoO_errmsg VARCHAR2(255);
         BEGIN
    StoO_rowcnt := 0;
    StoO_error := 0;
    StoO_selcnt := 0;
    P_RETURN := 0;
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES (P_STATE_CODE, P_CITY_CODE, P_CITY_NAME);
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN TOO_MANY_ROWS THEN
    StoO_rowcnt := 2;
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
              IF StoO_error != 0 THEN
    BEGIN
                   P_RETURN := 1;
         RETURN;
         END;
              END IF;
         END;
    CREATE OR REPLACE PROCEDURE SP_GETCITIES(
    STATE_KEY IN VARCHAR,
    RC1      IN OUT globalPkg.RCT1)
    AS
    StoO_error INTEGER;
    StoO_selcnt INTEGER;
    StoO_rowcnt INTEGER;
    StoO_errmsg VARCHAR2(255);
    BEGIN
    StoO_rowcnt := 0;
    StoO_error := 0;
    StoO_selcnt := 0;
    OPEN RC1 FOR
    SELECT STATE_CODE, CITY_CODE, CITY_NAME
    FROM CITIES
    WHERE STATE_CODE = STATE_KEY
    ORDER BY CITY_CODE;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
         END;
    /

    Hi Mark,
    Thanks for your recommendations.
    I change the code with OCIDefineByPos, one for each parameter from cursor and then use the OCIStmtFetch.
    I don´t receive a error when call OCIDefineByPos, but when I call OCIStmtFetch receive a -1 error number.
    What is wrong with the code?
    The script is the same.
    I need your help!
    Best Regards!
    Antonio Garcia (Mexico)
    This the new code:
    #include <stdio.h>
    #include <string.h>
    #include <oci.h>
    #include <stdlib.h>
      char*   pConnectChar ="ORAC617";
      char*   pUsernameChar = "C617_005_DBO_01";
      char*   pPasswordChar = "Tempora1";
      char*   sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
      int     retval;
      ub4 parmcnt=0;
      ub4 pos2=0;
      sb2   *c_indp;
      text *pcoln[20], *name,*name2;
      ub4 namelen[20],len;
      ub2 type,size;
      char state_key[5];
      OCIDefine        *pdef;
      OCIBind          *p_bnd;
      ub1          **c_buf;
      OCIStmt*     pOciStatement;      /* Statement handle */
      OCIStmt*     pOciStatCursor;     /* Statement handle */   
      OCIError*    pOciError;          /* Error handle */
      OCIEnv*      pOciEnviron;        /* Environment handle */
      OCIServer*   pOciServer;         /* Server handle */  
      OCISession*  pOciSession;        /* Session handle */
      OCISvcCtx*   pOciServiceContext; /* Service Context handle */
      OCIBind*     pOciBind[500];      /* Bind handle */
      OCIParam*    pOciParam;          /* Param handle */
      int OCI_Fetch(OCIStmt *p_select,OCIError *p_err, int *piOcc)
      int iOcc, rc; 
      rc=OCIStmtFetch(p_select,p_err,1,OCI_FETCH_NEXT,OCI_DEFAULT);
      printf("rc fetch %i",rc);
      if(rc==0&&piOcc!=NULL){
           printf("entro al if");
        iOcc=*piOcc;
        *piOcc=iOcc+1;
      return rc;
    int main()
    int pos,i=0,rc;
      retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
      printf("EnvCreate retval=%d\n", retval);
      retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
      printf("EnvInit retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_ERROR retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_SVCCTX retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
                  strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
                    (unsigned char *)pConnectChar,strlen(pConnectChar));
      printf("OCILogon retval=%d\n",retval);
      retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
                 OCI_NTV_SYNTAX, OCI_DEFAULT);
      printf("StmtPrepare retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
                 (sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
      printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
                 (sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
      printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
      strcpy(state_key,"CA");
      retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
                   (OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
      printf("StmtExecute retval=%d\n",retval);
      c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
      c_indp=(sb2 *)calloc(sizeof(sb2 *),3);
      // Get number of parameters of the Cursor
      OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
                  (ub4)OCI_ATTR_PARAM_COUNT, pOciError);
      printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
      for (pos = 1; pos <= (int)parmcnt; pos++)
           OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
                (ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
           retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,(ub4) pos );
           // Get the column name
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &name,(ub4 *) &len, (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
            // Get the column datatype
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &type,(ub4 *)0,(ub4)OCI_ATTR_DATA_TYPE,(OCIError *)pOciError);      
            // Get the column size
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &size,(ub4 *)0,(ub4)OCI_ATTR_DATA_SIZE,(OCIError *)pOciError);
           printf("Column %i\tNAME = %.*s \ttype %d \tsize %d\n",pos,len,name,type,size);
           // OCIDefine ByPos, one for each parameter
           // c_buf store the STATE_CODE, CITY_CODE and CITY_NAME columns from the cursor
           rc=OCIDefineByPos(pOciStatCursor,&pdef,(OCIError *)pOciError,pos,c_buf[pos-1],size+1,(ub2)type,(dvoid *)c_indp[pos-1],(ub2 *)0,(ub2 *)0,OCI_DEFAULT);     
          printf("OCIDefineByPos retval=%d\n,rc);
      // call OCIStmtFetch. In the next line, I receive the error
      rc=OCIStmtFetch(pOciStatCursor,pOciError,1,OCI_FETCH_NEXT,OCI_DEFAULT);
      printf("rc fetch %i",rc);
      return 0;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • How to start with XSLT Mapping

    Hi Everyone,     How to learn XSLT Mapping,Error Analysis,Triggering alerts and Trouble shooting in XI.Plz could anyone help to get through these areas?I'm facing many problems in my inetrviews in the above mentioned areas.I eagerly waiting for the r

  • JMS Adapter...

    Hi Frnds, I am working on one scenario using JMS Adapter, my requirement is i have to read messages from JMS Queue,suppose in Queue there is 20 messagesa have to read at a time 20 messages using JMS Adapter and merge into one message. JMS Adapter wl

  • Use of  T- Code CO1P

    Hi PP expert Can u tell me the use of  T- Code CO1P.(disply purpose ) If I excute that what happened.(It is use as like COGI). regards , NItu....

  • Need to check logic

    Hi , I have some doubt first I have take data from excel sheet check the existing record in excle fine and need to validate Edited by: anil kumar on Jan 22, 2008 5:06 PM

  • Cant find my library, only purchased music

    I just bought a new lap top.  I have my purchased music, but not my playists.  Please help