Problem calling Oracle function from Access 2007 / ADO

Hopefully, I'm posting this in the correct forum. I'm also posting on an Access forum as I'm not entirely sure where the issue lies.
I'm calling an Oracle function from Access 2007 using an ADO Command object.
The function takes three input parameters and has a return value and an output parameter. The output parameter is a BLOB, and the return value is varchar2 (either "T" or "N") based on the outcome of the function.
If I pass correct values to the function, I get the following error message (errs out on the command.execute line):
Run-time error '-2147467259 (80004005)':
[Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 1
Here's the function:
FUNCTION GET_ITEMREV_ATTACH(P_ORGANIZATION_ID IN NUMBER,
P_INVENTORY_ITEM_ID IN NUMBER,
P_REVISION IN VARCHAR2,
X_DRAWING OUT BLOB) RETURN VARCHAR2 IS
RESULT VARCHAR2(1);
BEGIN
RESULT := 'T';
BEGIN
SELECT L.FILE_DATA
INTO X_DRAWING
FROM FND_ATTACHED_DOCUMENTS AD,
MTL_ITEM_REVISIONS_B IR,
FND_DOCUMENTS_TL D,
FND_LOBS L
WHERE AD.ENTITY_NAME = 'MTL_ITEM_REVISIONS' AND
AD.PK1_VALUE = IR.ORGANIZATION_ID AND
AD.PK2_VALUE = IR.INVENTORY_ITEM_ID AND
AD.PK3_VALUE = IR.REVISION_ID AND
AD.CATEGORY_ID = 1001216 AND
D.DOCUMENT_ID = AD.DOCUMENT_ID AND
D.LANGUAGE = 'US' AND
L.FILE_ID = D.MEDIA_ID AND
IR.ORGANIZATION_ID = P_ORGANIZATION_ID AND
IR.INVENTORY_ITEM_ID = P_INVENTORY_ITEM_ID AND
IR.REVISION = P_REVISION;
EXCEPTION
WHEN OTHERS THEN
RESULT := 'N';
END;
RETURN(RESULT);
END GET_ITEMREV_ATTACH;
Here's the VB code I'm using to call the function:
Private Sub Command8_Click()
Dim CMD As New ADODB.Command
Dim conn As ADODB.Connection
Dim Param1 As ADODB.Parameter
Dim Param2 As ADODB.Parameter
Dim Param3 As ADODB.Parameter
Dim ParamBlob As ADODB.Parameter
Dim ParamReturn As ADODB.Parameter
Set conn = New ADODB.Connection
With conn
.ConnectionString = "Driver={Oracle in OraHome92};Dbq=OAPLY;UID=***;PWD=*******"
.CursorLocation = adUseClient
.Open
End With
Set CMD = New ADODB.Command
Set CMD.ActiveConnection = conn
CMD.CommandText = "immi_attach_pub.get_itemrev_attach"
CMD.CommandType = adCmdStoredProc
Set ParamReturn = CMD.CreateParameter("RESULT", adVarChar, adParamReturnValue, 1)
CMD.Parameters.Append ParamReturn
Set Param1 = CMD.CreateParameter("P_ORGANIZATION_ID", adInteger, adParamInput, 1, 6)
CMD.Parameters.Append Param1
Set Param2 = CMD.CreateParameter("P_INVENTORY_ITEM_ID", adInteger, adParamInput, 4, 5207)
CMD.Parameters.Append Param2
Set Param3 = CMD.CreateParameter("P_REVISION", adVarChar, adParamInput, 2, "04")
CMD.Parameters.Append Param3
Set ParamBlob = CMD.CreateParameter("X_DRAWING", adLongVarBinary, adParamOutput, 200000)
CMD.Parameters.Append ParamBlob
CMD.Execute , , adExecuteNoRecords *** this is where the error occurs
conn.Close
MsgBox CMD.Parameters("RESULT")
End Sub
I've tried using different data types for the varchar2 parameters (adVarChar, adBSTR, adChar) with no difference.
If I pass a bogus value for Param3...."'04'"...the function returns "N" indicating that it actually executed something. But, when I pass the correct value "04", it returns the above mentioned error.
I can execute the function in PL/SQL just fine, so I'm thinking there's something wrong with the parameters, datatype, or other definitions on the Access side.
Does anyone have any thoughts? I'm at a dead end with this. Sorry for the long post. Thank you.

I tried your code with 11107 ODBC/client/database (but with a NULL output blob for convenience sake) and got no errors.
If you're using 92 ODBC/client, you may want to try upgrading to something more current, or at least getting the latest patch(9208) to see if that helps. Since it works for me I'm guessing it may be a resolved bug in that version.
Hope it helps,
Greg

Similar Messages

  • Calling oracle function from access

    does anyone know if it s possible to call a oracle pl/sql function from access ?
    thx in advance
    Andre

    As long as you do not need a return value from the procedure, you can call it from Access.
    Create a QueryDef object as a sql pass through query. Make sure that you set the ReturnsRecords property of the QueryDef to false. Set the SQL property of the QueryDef to the correct syntax to execute your procedure, then call the Execute method of the QueryDef object.

  • Calling oracle function from Access passthrough query does not return list

    Thanks to the help I received in an earlier post I've created an oracle 10g function that returns a list after executing the sql it contains. It works in oracle, using sql developer.
    I need to have the list that it returns show up in MS Access via a passthrough query. It's not working so far. The connection string etc is ok, I'm able to use passthrough queries to run sql strings successfully. But when I try to call the function via the Access passthrough query at first nothing seems to happen (ie no list appears) and if I try to run it again, there is a odbc error 'call in progress. Current operation canceled'. There are only the three records in the table. I'm missing something, can anyone spot it?
    The passthrough query looks like this
    select * from fn_testvalues from dual
    Again that runs in oracle.
    To create the testing table and 2 functions see below.
    CREATE TABLE t_values (MyValue varchar2(10));
    Table created
    INSERT INTO t_values (
    SELECT 'Merced' c1 FROM dual UNION ALL
    SELECT 'Pixie' FROM dual UNION ALL
    SELECT '452' FROM dual);
    3 rows inserted
    CREATE OR REPLACE FUNCTION fn_isnum(p_val VARCHAR2) RETURN NUMBER IS
    n_val NUMBER;
    BEGIN
    n_val := to_number(p_val);
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END;
    Function created
    testing the table:
    SELECT val, fn_isnum(MyValue ) isnum
    FROM t_values;
    VAL ISNUM
    Merced 0
    Pixie 0
    452 1
    Now the function that is called in the passthrough query:
    create or replace function fn_testvalues
    return sys_refcursor is
    rc sys_refcursor;
    begin
    open rc for
    Select t_values.*, fn_isnum(MyValue) IsNum from t_values;
    return(rc);
    end fn_testvalues;

    lecaro wrote:
    OK. But obviously there is some oracle object that one can call via an Access pass-through query which returns rows?Just to clarify. You could fetch data in Access from an Oracle function that returns a ref cursor using VBA editor. To use a pass-through query Oracle function should be a table function or pipelined table function:
    CREATE OR REPLACE
      TYPE testvalues_obj_type
        AS OBJECT(
                  val varchar2(10),
                  isnum number
    CREATE OR REPLACE
      TYPE testvalues_tbl_type
        AS TABLE OF testvalues_obj_type
    CREATE OR REPLACE
      FUNCTION fn_testvalues
        RETURN testvalues_tbl_type
        PIPELINED
        IS
            CURSOR testvalues_cur
              IS
                SELECT  testvalues_obj_type(MyValue,fn_isnum(MyValue)) testvalues_obj
                  FROM  t_values;
        BEGIN
            FOR v_rec IN testvalues_cur LOOP
              PIPE ROW(v_rec.testvalues_obj);
            END LOOP;
            RETURN;
    END;
    /To test it in Oracle:
    SELECT  *
      FROM  TABLE(fn_testvalues)
    VAL             ISNUM
    Merced              0
    Pixie               0
    452                 1
    SQL> Now in Access pass-trough query window enter:
    SELECT  *
      FROM  TABLE(fn_testvalues);SY.

  • Calling ORACLE Functions from within CF Builder report

    Hi, I have an ORACLE function that I would like to call from within my CF REPORT.
    I know there is a section in the report builder where you can write coldfusion code to perform tasks, but I would rather simply call the ORACLE function for each detail row in the report
    I do not want to call this function from within my main ORACLE query that I use for the report, so please don't suggest that.
    Thanks so much.
    -Jim

    6.0.5 is not certified against 10g database, so I suggest to upgrade to 6.0.8.26 (6i patch 17) first to see if the problem is gone.

  • Error establishing ODBC connection to Oracle database from Access 2007

    I am trying to access via linked tables from Access 2007 my ODBC connections.
    I am able to setup and test successfully in the ODBC Data Source Administrator my Data source, and Driver(Oracle in OraHome92), and I used this successfully when I had Access 2003 on this PC.
    system details: Oracle 9i, MS Access 2007 on Windows XP
    error - call failed:
    detailed error from sqlnet.log:
    Fatal NI connect error 12560, connecting to:
    (DESCRIPTION=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleORCL)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))'))(CONNECT_DATA=(SID=ORCL)(CID=(PROGRAM=C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE)(HOST=USRN4WNCNH6DDQG)(USER=fznp29))))
    VERSION INFORMATION:
         TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
         Oracle Bequeath NT Protocol Adapter for 32-bit Windows: Version 9.2.0.1.0 - Production
    Time: 05-DEC-2008 11:38:05
    Tracing not turned on.
    Tns error struct:
    nr err code: 0
    ns main err code: 12560
    TNS-12560: TNS:protocol adapter error
    ns secondary err code: 0
    nt main err code: 530
    TNS-00530: Protocol adapter error
    nt secondary err code: 126
    nt OS err code: 0
    Any ideas?

    Hi,
    Please can you specify how you create your DSN for Oracle connection in ODBC Data Source Administrator?
    What did you specify for the TNS Service Name?
    What is the content of your TNSNAMES.ORA file?
    Thx
    Mireille

  • How to call oracle function from ejb3

    i'm trying to call an oracle query-function from ejb3.
    The oracle function:
    create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
    RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
    m_sql VARCHAR2(250);
    BEGIN
    m_sql:='select count(thrId) from thread where secId='|| secid||'
    and thrAvai='|| avai;
    open cur for m_sql;
    return cur;
    END;
    I'v tried several ways to call it,but all failed:
    1. the calling code:
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");     
              query.setParameter(1, secId);
              query.setParameter(2, avai);
              return query.getSingleResult();
    but i got the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
    PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
    ORA-06550: row 1, col 7:
    PL/SQL: Statement ignored
    2. the calling code:
    @SqlResultSetMapping(name = "getSecThreadCount_Mapping")
    @NamedNativeQuery(name = "getSecThreadCount",
    query = "{?=call getSecThreadCount(:secId,:avai)}",
    resultSetMapping = "getSecThreadCount_Mapping",
    hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
              @QueryHint(name = "org.hibernate.readOnly", value = "true")})
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNamedQuery("getSecThreadCount");     
              query.setParameter("secId", secId);
              query.setParameter("avai", avai);
              return query.getSingleResult();
    but i run into the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
    By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
    Could anyone tell me how to call the function from EJB3?
    Thanks.

    Here's a working model:
    package.procedure: (created in example schema scott)
    CREATE OR REPLACE package  body data_pkg as
      type c_refcursor is ref cursor;
      -- function that return all emps of a certain dept
      function getEmployees ( p_deptId in number
      return c_refcursor
      is
        l_refcursor c_refcursor;
      begin
         open l_refcursor
        for
              select e.empno as emp_id
              ,        e.ename as emp_name
              ,        e.job   as emp_job
              ,        e.hiredate as emp_hiredate
              from   emp e
              where  e.DEPTNO = p_deptId;
        return l_refcursor;
      end getEmployees;
    end data_pkg;
    /entity class:
    package net.app.entity;
    import java.io.Serializable;
    import java.util.Date;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedNativeQuery;
    import javax.persistence.QueryHint;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @SuppressWarnings("serial")
    @Entity
    @Table (name="emp")
    @SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
    @NamedNativeQuery( name = "getEmpsByDeptId"
                   , query = "{ ? = call data_pkg.getEmployees(?)}"
                   , resultClass = Employee.class
                   , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
                          , @QueryHint(name = "org.hibernate.readOnly", value = "true")
    public class Employee implements Serializable
        @Id
        @Column(name="emp_id")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
        private int id;
        @Column(name="emp_name")
        private String name;
        @Column(name="emp_job")
        private String job;
        @Column(name="emp_hiredate")
        private Date hiredate;
        // constructor
        public Employee (){}
        // getters and setters
        public int getId()
         return id;
    etc...session bean:
    package net.app.entity;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    @Stateless
    public class ScottAdminImpl implements ScottAdmin
        @PersistenceContext
        private EntityManager entityManager;
        @SuppressWarnings("unchecked")
        public List<Employee> getEmployeesByDeptId(int deptId)
         ArrayList<Employee> empList;
         try
             Query query = entityManager.createNamedQuery("getEmpsByDeptId");
             query.setParameter(1, deptId);
             empList = (ArrayList<Employee>) query.getResultList();
             return empList;
         catch (Exception e)
             e.printStackTrace(System.out);
             return null;
    }client:
    package net.app.client;
    import java.util.List;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    public class ScottClient
        public static void main(String[] args)
         try
             // create local interface
             InitialContext ctx = new InitialContext();
             ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
             // select employees by deptno
             int deptno = 20;
             List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
             // output
             System.out.println("Listing employees:");
             for (Employee emp : empList)
              System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
         catch (NamingException e)
             e.printStackTrace(System.out);
    }Basically you just ignore the refcursor outbound parameter.
    This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
    Edited by: _Locutus on Apr 2, 2009 2:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Call Oracle function from Stored Procedure

    Hi,
    I have function Which returning one number. I want to use that number in a procedure. How to call the Oracle Function from the Procedure
    Create procedure
    AS
    Begin
    Check number;
    Select Function1 into check from dual;
    It is giving error.
    Can anyone provide me example for this.
    Thanks in advance

    Put the Check Number; before begin
    SQL> create or replace procedure abc as
      2 begin
    3 val number;
      4  select abcd into val from dual;
      5  dbms_output.put_line(val);
      6  end;
      7  /
    Warning: Procedure created with compilation errors.
    Elapsed: 00:00:00.00
    SQL> show error
    Errors for PROCEDURE ABC:
    LINE/COL ERROR
    3/5      PLS-00103: Encountered the symbol "NUMBER" when expecting one of
             the following:
             := . ( @ % ;
             The symbol ":=" was substituted for "NUMBER" to continue.
    SQL> create or replace procedure abc as
      2 val number;
    3 begin
      4  select abcd into val from dual;
      5  dbms_output.put_line(val);
      6  end;
      7  /
    Procedure created.
    Elapsed: 00:00:00.00
    SQL> exec abc;
    100.22
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL>

  • Problem calling oracle SP from Java

    Hi I am trying to call an oracle SP from Java program and getting the error code 17060. Below is my code:
    Oracle SP:
    create or replace type item as object (itemnumber varchar2(9),itemdesc varchar2(35));
    create or replace type uom as object (prodUOM varchar2(18), ratioDen NUMBER(1));
    CREATE OR REPLACE TYPE uom_Arr aS VARRAY(100) OF uom;
    create or replace package test_pkg_xml is
    procedure test_sp_xml (item_rec item,
    uom_tbl uom_arr);
    end test_pkg_xml;
    create or replace package body test_pkg_xml is
    procedure test_sp_xml (item_rec item,
    uom_tbl uom_arr)
    is
    begin
    null;
    end;
    end test_pkg_xml;
    Java Code
    public class item implements SQLData {
    private String sql_type;
    public String itemnumber ;
    public String itemdesc ;
    public String getSQLTypeName() throws SQLException { return sql_type; }
    public void readSQL(SQLInput stream, String typeName)throws SQLException
    sql_type = typeName;
    itemnumber = stream.readString();
    itemdesc = stream.readString();
    public void writeSQL(SQLOutput stream) throws SQLException
    System.out.println("in write sql");
    stream.writeString (itemnumber);
    stream.writeString (itemdesc);
    package com.tgt.dstb.dwm.dstbtowm.dao;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.sql.Connection;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Types;
    import java.sql.SQLException;
    import java.util.Map;
    import java.util.Hashtable;
    public class TestDOM
    public static void test(Connection conn) throws Exception
    item obj1 = new item();
    Obj2 obj2 = new Obj2();
    Obj2[] obj3 = {new Obj2(), new Obj2()};
    String sql = "call " + "test_pkg_xml.test_sp_xml(?,?)";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser = factory.newDocumentBuilder();
    Document document = parser.parse( "item.xml" );
    Element itemMaster = document.getDocumentElement();
    NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
    NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
    System.out.println("Item = ");
    String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
    String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
    obj1.itemnumber = itmname;
    obj1.itemdesc = itmdesc;
    System.out.println("itmname = " + obj1.itemnumber );
    System.out.println("itmdesc = " + obj1.itemdesc );
    NodeList uoms = itemMaster.getElementsByTagName("uoms");
    NodeList uom = itemMaster.getElementsByTagName("uom");
    System.out.println("uom = ");
    for( int i=0; i<uom.getLength(); i++ ) {
    String itmprodUOM = DOMUtil.getSimpleElementText(
    (Element)uom.item(i),"prodUOM" );
    obj3.prodUOM = itmprodUOM;
    String itmratioDen = DOMUtil.getSimpleElementText(
    (Element)uom.item(i), "ratioDen" );
    obj3[i].ratioDen = itmratioDen;
    System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
    try
    Hashtable map = new Hashtable();
    map.put ("item", Class.forName ("com.tgt.dstb.dwm.dstbtowm.dao.item"));
    conn.setTypeMap(map);
    System.out.println("here 11111 ");
    CallableStatement stmt = conn.prepareCall("call test_pkg_xml.test_sp_xml(?,?)");
    System.out.println("here 2 ");
    stmt.setObject(1,obj1);
    System.out.println("here 3 ");
    stmt.setObject(2,obj3);
    System.out.println("here 4 ");
    stmt.execute();
    System.out.println("here 5 ");
    }catch (SQLException e)
    System.out.println("exception :"+e.getErrorCode());
    Can you please point out where I might be going wrong with the code? Any help would be greatly appreciated.
    PS : I am getting the error 17060 after the stmt : System.out.println("here 2 ");
    Thanks,
    Nitin

    Avi, I changed my code to:
    package com.tgt.dstb.dwm.dstbtowm.dao;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.sql.Connection;
    //import java.sql.CallableStatement;
    import java.sql.*;
    //import java.util.Map;
    //import java.util.Hashtable;
    import oracle.sql.ArrayDescriptor;
    import oracle.sql.*;
    import oracle.jdbc.*;
    public class TestDOM
    public static void test(Connection conn) throws Exception
         item obj1 = new item();
         Obj2 obj2 = new Obj2();
         Obj2[] obj3 = {new Obj2(), new Obj2()};
         String sql = " call test_pkg_xml.test_sp_xml(?,?)";
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser = factory.newDocumentBuilder();
    Document document = parser.parse( "item.xml" );
    Element itemMaster = document.getDocumentElement();
    NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
    NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
    System.out.println("Item = ");
    String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
    String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
    obj1.itemnumber = itmname;
    obj1.itemdesc = itmdesc;
    System.out.println("itmname = " + obj1.itemnumber );
    System.out.println("itmdesc = " + obj1.itemdesc );
    NodeList uoms = itemMaster.getElementsByTagName("uoms");
    NodeList uom = itemMaster.getElementsByTagName("uom");
    System.out.println("uom = ");
    for( int i=0; i<uom.getLength(); i++ ) {
    String itmprodUOM = DOMUtil.getSimpleElementText(
    (Element)uom.item(i),"prodUOM" );
    obj3.prodUOM = itmprodUOM;
    String itmratioDen = DOMUtil.getSimpleElementText(
    (Element)uom.item(i), "ratioDen" );
    obj3[i].ratioDen = Integer.parseInt(itmratioDen);
    System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
    try
    System.out.println("here 1 ");
    OracleCallableStatement stmt = (OracleCallableStatement)
    conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");
    System.out.println("here 1.1 ");
    System.out.println("here 1.2 ");
    ArrayDescriptor desc1 = ArrayDescriptor.createDescriptor("UOM_ARR", conn);
         ARRAY array_to_pass1 = new ARRAY(desc1, conn, obj3);
    System.out.println("here 2 ");
    stmt.setObject(1,obj1,OracleTypes.STRUCT);
    System.out.println("here 3 ");
    stmt.setArray(2,array_to_pass1);
    System.out.println("here 4 ");
    stmt.execute();
    System.out.println("here 5 ");
         }catch (Exception e)
              e.printStackTrace();
    However, now I the code is printing
    "here 1 "
    and then giving
    "[1/4/07 11:37:28:133 CST] 00000036 SystemErr R java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement"
    at "OracleCallableStatement stmt = (OracleCallableStatement)
    conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");"
    statement.
    I am using Rational App Developer Version 6.0.1 and getting a connection using
    the below code:
              DataSource     dataSource=null ;
              Context jndiContext = new InitialContext();
              dataSource =
    (DataSource)jndiContext.lookup("java:comp/env/jdbc/DWM3DDS");
              Connection wsConn = dataSource.getConnection();
    Looks like this exception occurs when I am casting java.sql.Connection object to OracleCallableStatement. Do you have any idea why this might be occuring? Have you encountered this kind of a problem?
    Thanks,
    Nitin

  • Call Oracle Function from ASP++++!

    I have a lot of Oracle function in packages and i would like use it in my ASP pages.
    With Oracle procedure it's all right.
    Sample like this
    set cn = Server.CreateObject("ADODB.Connection")
    connString = "Provider=MSDAORA.1;Data Source=<>;User ID=<>;Password=<>"
    cn.Open connString
    SQL = "{call test.test_asp({resultset 0, cResult})}"
    Set cmd = Server.CreateObject ("ADODB.Command")
    Set cmd.ActiveConnection = cn
    cmd.CommandText = SQL
    cmd.CommandType = 1     'adCmdText
    Set rs = Server.CreateObject ("ADODB.RecordSet")
    Set rs = cmd.Execute
    If NOT (rs.BOF and rs.EOF) Then
    Do while NOT rs.EOF
    <%=rs("dfcountry")%>
    <%=rs("dfname")%>
    rs.MoveNext
    LOOP     
    End if
    And in package TEST i have
    PROCEDURE TEST_ASP(cResult IN OUT ResultCursor)
    IS
    BEGIN
    OPEN cResult FOR
    SELECT *
    FROM tcountry;
    END TEST_ASP;"
    I Hope You help me with similar call a function!!!
    For example, this is one
    FUNCTION test_fun
    RETURN resultcursor
    IS
    vres resultcursor;
    BEGIN
    OPEN vres FOR
    SELECT *
    FROM tcountry;
    RETURN vres;
    END test_fun;

    Stored Procedures
    When executing an Oracle PL/SQL stored procedure using a command, use Oracle native syntax or the ODBC procedure call escape sequence in the command text:
    Oracle native syntax: BEGIN credit_account(123, 40); END;
    ODBC syntax: {CALL credit_account(123, 40)}
    Preparing Commands
    OraOLEDB validates and fetches the metadata only for SELECT SQL statements.
    Command Parameters
    When using Oracle ANSI SQL, parameters in the command text are preceded by a colon. In ODBC SQL, parameters are indicated by a question mark ("?").
    OraOLEDB supports input, output, and input/output parameters for PL/SQL stored procedures and stored functions. OraOLEDB supports input parameters for SQL statements.
    Joel P�rez

  • Problems calling a function from another function

    Hello all.
    I am trying to create a function that will loop a few other function.
    Basically the main function is this
                        private function publish(event:MouseEvent):void
                            if (doPublish.label == 'Publish')
                                // create a new NetStream object for video publishing
                                nsPublish = new NetStream(nc);
                                nsPublish.addEventListener(NetStatusEvent.NET_STATUS, nsPublishOnStatus);
                                // set the buffer time to zero since it is chat
                                nsPublish.bufferTime = 0;
                                // publish the stream by name
                                nsPublish.publish(publishName.text);
                                // add custom metadata to the stream
                                var metaData:Object = new Object();
                                metaData["description"] = "Chat using VideoChat example."
                                nsPublish.send("@setDataFrame", "onMetaData", metaData);
                                // attach the camera and microphone to the server
                                nsPublish.attachCamera(camera);
                                nsPublish.attachAudio(microphone);
                                doPublish.label = 'Stop';
                            else
                                // here we are shutting down the connection to the server
                                nsPublish.attachCamera(null);
                                nsPublish.attachAudio(null);
                                nsPublish.publish("null");
                                nsPublish.close();
                                doPublish.label = 'Publish';
    I am then trying to call that function like this
                protected function startloop():void {
                    publish(event);
    But i get the error Access of undefined property event.
    Any ideas on how i can call this function ?  I need to call it as part of a loop against a timer..
    Thanks in advance

    Need more info. Are you using a ViewStack or other navigator container, and trying to access a view that has not been displayed yet, due to deferred instantiation?
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex Training and Support Services

  • Calling oracle functions from PreparedStatement

    Hi everybody,
    I have got the transaction rolled back when I tried to call HexToRaw() function of oracle to insert raw data into a table. The raw data column is of size 30 chars.
    Part of my prepared statement is :
    " VALUES(?,?,?, HEXTORAW(00000000000000000000000000000000),?,?) "
    I just need to insert a sequence of zeroes into the column, so no setBytes() needed i guess.
    Any help will be apprciated.
    Thank you all.

    Could anyone please reply....

  • Calling oracle Function from java

    first of all ... i don't know english very vell and sorry about it ..... then ...
    i've created table in oracle :
    create table STUDENT
    ID NUMBER,
    NAME VARCHAR2(50),
    SURNAME VARCHAR2(50),
    AGE NUMBER
    and than i've wrote function like that :
    create or replace function sf_SearchStudent
    nID in number
    return MyPackage.CursorType is
    Result MyPackage.CursorType;
    begin
    open Result for select * from STUDENT where ID=nID;
    return Result;
    end sf_SearchStudent;
    and it's working fine but in java i wrote code like that :
    CallableStatement callst = conn.prepareCall("{?=call sf_SearchStudent(?,?,?,?)}");
    callst.registerOutParameter(1, OracleTypes.CURSOR);
    callst.setInt(1,id);
    callst.setString(2,name);
    callst.setString(3,surname);
    callst.setInt(4,age);
    callst.executeUpdate(); ------->>>>> ERROR Occur
    ResultSet res = ((OracleCallableStatement)callst).getCursor(1);
    while (res.next())
    System.out.println(res.getInt("ID"));
    System.out.println(res.getString("NAME"));
    System.out.println(res.getString("SURNAME"));
    System.out.println(res.getInt("AGE"));
    but here is an error and i don't know why :( ....... please help me ..... F!
    error type :
    java.sql.SQLException: Missing IN or OUT parameter at index:: 5

    no it's not a problem ........ I so already tried, but a mistake all the same was. After that I a little bit simplified.
    ok consequently i did oracle procedure like that :
    create or replace function sf_SearchStudent
    nID in number
    return MyPackage.CursorType is
    wCursor MyPackage.CursorType;
    begin
    open wCursor for Wselect;
    return wCursor;
    end sf_SearchStudent;
    and the java source code looks like that :
    CallableStatement callst = conn.prepareCall("{?=call sf_SearchStudent(?,?,?,?)}");
    callst.registerOutParameter(1, OracleTypes.CURSOR);
    callst.setString(1, name);
    callst.executeUpdate(); ------------------>>>>>>>>>> HERE IS AN ERROR ------------<<<<<<<<<<<<
    ResultSet res = ( (OracleCallableStatement) callst).getCursor(4);
    while (res.next())
    System.out.println(res.getInt("ID"));
    System.out.println(res.getString("NAME"));
    System.out.println(res.getString("SURNAME"));
    System.out.println(res.getInt("AGE"));
    error type :
    java.sql.SQLException: Missing IN or OUT parameter at index:: 3

  • JAVA Calling Oracle Function and Returning OBJECT

    HI,
    I am working as a developer in java/j2ee project.
    I am facing one issue:
    I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
    Can you please help me
    With Best Regards

    golduniya wrote:
    I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
    Can you please help meIt requires a great deal of Oracle jdbc driver specific code.
    [http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraint.htm#1012664]

  • Can LabVIEW call a function from a .sys file or is LabVIEW limited to dll access?

    My vendor has sent me a .sys file with functions accessing their hardware.  Can i call these function from labview directly or do I have to wrapper the .sys with a dll?

    Well a sys file is a kernel device driver. LabVIEW does not have any direct way of accessing such a driver. The way kernel drivers are accessed is usually through a DLL which makes calls to WinAPI functions such as CreateFile(), ReadFile(), WriteFile(), CloseHandle() and DeviceIORequest(). Since these WinAPI calls are basically just DLL calls too, you could theoretically use the Call Library Node to call them and access the kernel device driver in such a way.
    However for any kernel device driver with more than one or two device driver calls, it will certainly be easier in terms of development, debugging and maintenance of the code, to write actually a dedicated DLL in C/C++ for this device driver and access that DLL from LabVIEW, especially if you consider the LabVIEW datatype limitations when designing the DLL interface (Basically this same DLL can then be called from any other Windows development environment, be it Visual Basic (similar datatype limitation as LabVIEW), Delphi, (Visual) C, LabVIEW or also various scripting environments like Python and Lua.
    Some of the necessary WindAPI calls are rather involved and pose quite a bit of trouble to get the parameter data right in LabVIEw.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Trying to call a function from C#

    Hi all,
    I am having problems calling a function that returns a sys refcursor and takes a varchar2 as an input. From the SQL Developer IDE I see that the function is run like
    DECLARE
    X_AR_MHTR VARCHAR2(200);
    v_Return sys_refcursor;
    BEGIN
    X_AR_MHTR := 697678;
    v_Return := CMS_SMS.FOR_WEB.WEB_STATION_1(
    X_AR_MHTR => X_AR_MHTR
    /* Legacy output:
    DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
    :v_Return := v_Return; --<-- Cursor
    END;
    here is my C# code
    public static void getTilemetriseis(bool isLemessos, string AMSet, out OracleDataReader dr)
    DataSet ds = new DataSet();
    OracleDataAdapter ad = new OracleDataAdapter();
    OracleCommand cmd = new OracleCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "CMS_SMS.FOR_WEB.WEB_Station_1";
    if (isLemessos)
    cmd.Parameters.Add("X_AR_MHTR", OracleDbType.Varchar2, ConfigurationManager.AppSettings["LemessosArMhtr"].ToString(), ParameterDirection.Input);
    cmd.Parameters.Add(new OracleParameter("anexoflCur", OracleDbType.RefCursor, ParameterDirection.ReturnValue));
    // ad.SelectCommand.CommandText = string.Format(@"select m_code,ar_mhtr,city,address,stcode
    // from cms_sms.FOR_WEB.flowmetersall where ar_mhtr = {0}
    // order by length(ar_mhtr),ar_mhtr", ConfigurationManager.AppSettings["LemessosArMhtr"].ToString());
    else
    cmd.Parameters.Add("X_AR_MHTR", OracleDbType.Varchar2, "697678", ParameterDirection.Input);
    cmd.Parameters.Add(new OracleParameter("v_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue));
    // ad.SelectCommand.CommandText = string.Format(@"select m_code,ar_mhtr,city,address,stcode
    // from cms_sms.FOR_WEB.flowmetersall where ar_mhtr= -1
    // order by length(ar_mhtr),ar_mhtr", AMSet);
    cmd.Connection = OracleDBManager.getOracleCMSConnection();
    cmd.ExecuteNonQuery();
    dr = (OracleDataReader)cmd.Parameters["v_Return"].Value;
    cmd.Connection.Close();
    The error rises on cmd.ExecuteNonQuery() and is described as
    ORA-06550:
    PLS-00306: wrong number or type of argument
    Any ideas?

    Off the top of my head, your parameter type on the second parameter is wrong. The function doesn't have a return value, one of the parameters contains it. So the second parameter's type can't be ReturnValue (should be output).
    Either that or change the function to only have one parameter and add RETURN sys_refcursor into the definition, at which point you can use ReturnValue.
    Here's an example: http://stackoverflow.com/questions/1773534/what-is-the-right-way-to-call-an-oracle-stored-function-from-ado-net-and-get-the
    Edited by: Tridus on Mar 20, 2013 10:24 AM

Maybe you are looking for

  • Problem with RBDMIDOC in executing for diff logical systems

    Hi ALL, We are using message type HRMD_A and we have configured two logical systems using that message.So when we execute RBDMIDOC to generate idoc for change pointers  it triggers idocs to both the logical system which we dont want.Is there any othe

  • ITunes locks up my Start Menu

    Has anyone ever run into this? I have iTunes on three machines - my home PC, my work PC, and a laptop. I use an external hard drive to hold my library and all audio files so I can listen to whatever I want any time. The last week or so, on my work PC

  • Minimizing & closing multiple grouped windows from taskbar

    On Windows Server 2012 R2, I have set my taskbar to combine buttons. I have multiple instances of a console application running, and they combine on the taskbar fine. However, when I right-click on the combined button, I only get a list of window nam

  • Where can download Adobe Presenter 9?

    I had to re-install Adobe presenter 9, but with the new upgrade to 10 the download for Adobe Presenter 9 is no longer available. Is there another link I can use to download?

  • What is my broswer version and how can i find a good spellchecker

    1. What is my browser version ? 2. How do i find a good spellchecker for my browser version ?