Using BC4J to pass an array to a stored function

I have successfully implemented the use of BC4J view objects to pass and retrive values from a stored database procedure/function as per Steve Muench's paper.
What I am having difficulty achieving is passing through an array to a stored function. I have a multiple selection table where on submit, I retrieve the selected values and want to be able to put them in a array and pass them to a stored function.
At the database level, I have created a nested table with one of the columns being a table of numbers. A wrapper function is called with the array type being one of the in parameters and the database updated.
I am however having no luck building the array in my Java code and passing it to the database through an expert-only view object.
I have :
1. Database wrapper function has an extra parameter for the table of numbers (number(10))
2. Changed the view object query to include the extra parameter (of type Number[])
3. Changed the relevant view object and transaction Impl classes to pass through an array of oracle.jbo.domain.Number
4. Update my test module class to
-- Test module class
String _am = "transaction2.transaction2module", _cf = "Transaction2ModuleLocal";
    String str1 = "String1";
    String str2 = "String2";
    String str3 = "String3";
    Number[] num4 = {new Number(1001),new Number(1002),new Number(1003),new Number(1004)};
    Transaction2Module testModule = (Transaction2Module)Configuration.createRootApplicationModule(_am,_cf);
    TxnResultType txnResult = testModule.getTxnResult(str1,str2,str3,num4);
-- Transaction2ModuleImpl.java
public ProcessTransactionImpl getProcessTxn()
    return (ProcessTransactionImpl)findViewObject("ProcessTxn");
  public TxnResultType getTxnResult(String p1, String p2, String p3, Number[] p4)
    return getProcessTxn().getTxnResult(p1, p2, p3, p4);
-- ProcessTxnImpl.java
public TxnResultType getTxnResult(String p1, String p2, String p3, Number[] p4)
    setWhereClauseParam(0,p1);
    setWhereClauseParam(1,p2);
    setWhereClauseParam(2,p3);
    setWhereClauseParam(3,p4);
    executeQuery();
    return ((ProcessTransactionRowImpl)first()).getTxnResult();
  }but the error message given is :
oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: select transaction_wrapper(:0, :1, :2, :3) as txn_result from dual
java.sql.SQLException: Invalid column type
     void oracle.jdbc.dbaccess.DBError.throwSqlException(java.lang.String, java.lang.String, int)
Can anyone offer some suggestions ?
Thanks,
Brent

Thanks for the reply - I had nearly given up on this ! I did add the setWhereClause statement as you suggested
setWhereClause("p1=:0 and p2=:1 and p3=:2 and p4=:3");but still got the same error. I have posted the entire output which may help you see what's still going wrong (hopefully!)
oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. 
Statement: SELECT * FROM (select test_array(:0,:1,:2,:3) as result from dual) QRSLT  WHERE (p1=:0 and p2=:1 and p3=:2 and p4=:3)
     void oracle.jbo.server.QueryCollection.executeQuery(java.lang.Object[], int)
          QueryCollection.java:541
     void oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(java.lang.Object, java.lang.Object[], int)
          ViewObjectImpl.java:2650
     void oracle.jbo.server.ViewRowSetImpl.execute(boolean, boolean)
          ViewRowSetImpl.java:523
     void oracle.jbo.server.ViewRowSetImpl.executeQuery()
          ViewRowSetImpl.java:564
     void oracle.jbo.server.ViewObjectImpl.executeQuery()
          ViewObjectImpl.java:2614
     java.lang.String mypackage5.TxnViewImpl.getResult(java.lang.String, java.lang.String, java.lang.String, oracle.jbo.domain.Number[])
          TxnViewImpl.java:25
     java.lang.String mypackage5.TransModuleImpl.getResult(java.lang.String, java.lang.String, java.lang.String, oracle.jbo.domain.Number[])
          TransModuleImpl.java:29
     void mypackage5.TestArray.main(java.lang.String[])
          TestArray.java:17
## Detail 0 ##
java.sql.SQLException: Invalid column type
     void oracle.jdbc.dbaccess.DBError.throwSqlException(java.lang.String, java.lang.String, int)
          DBError.java:187
     void oracle.jdbc.dbaccess.DBError.throwSqlException(int, java.lang.Object)
          DBError.java:229
     void oracle.jdbc.dbaccess.DBError.throwSqlException(int)
          DBError.java:292
     void oracle.jdbc.driver.OraclePreparedStatement.setObject(int, java.lang.Object, int, int)
          OraclePreparedStatement.java:2782
     void oracle.jdbc.driver.OraclePreparedStatement.setObject(int, java.lang.Object)
          OraclePreparedStatement.java:2905
     boolean oracle.jbo.server.ViewRowSetImpl.bindParameters(java.lang.Object[], java.sql.PreparedStatement)
          ViewRowSetImpl.java:1313
     void oracle.jbo.server.QueryCollection.executeQuery(java.lang.Object[], int)
          QueryCollection.java:511
     void oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(java.lang.Object, java.lang.Object[], int)
          ViewObjectImpl.java:2650
     void oracle.jbo.server.ViewRowSetImpl.execute(boolean, boolean)
          ViewRowSetImpl.java:523
     void oracle.jbo.server.ViewRowSetImpl.executeQuery()
          ViewRowSetImpl.java:564
     void oracle.jbo.server.ViewObjectImpl.executeQuery()
          ViewObjectImpl.java:2614
     java.lang.String mypackage5.TxnViewImpl.getResult(java.lang.String, java.lang.String, java.lang.String, oracle.jbo.domain.Number[])
          TxnViewImpl.java:25
     java.lang.String mypackage5.TransModuleImpl.getResult(java.lang.String, java.lang.String, java.lang.String, oracle.jbo.domain.Number[])
          TransModuleImpl.java:29
     void mypackage5.TestArray.main(java.lang.String[])
          TestArray.java:17
Exception in thread main
Process exited with exit code 1.I had to do a new example as I could not find the code I was using earlier. This is my java class
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.Number;
import mypackage5.common.TransModule;
public class TestArray
  public static void main(String[] args)
    String _am = "mypackage5.TransModule", _cf = "TransModuleLocal";
    String str1 = "String1";
    String str2 = "String2";
    String str3 = "String3";
    Number[] num4 = {new Number(1001),new Number(1002),new Number(1003),new Number(1004)};
    TransModule testModule = (TransModule)Configuration.createRootApplicationModule(_am,_cf);
    String txnResult = testModule.getResult(str1,str2,str3,num4);
    System.out.println("Result = " + txnResult);

Similar Messages

  • How to pass an array to a stored procedure

    create or replace package demo_pkg
    as
    type cityArray is table of city%rowtype index by binary_integer;
    procedure city_report( p_inputs in cityArray );
    end;
    CREATE OR REPLACE PACKAGE BODY demo_pkg
    AS
    PROCEDURE city_report (p_inputs IN cityarray)
    IS
    BEGIN
    FOR i IN 1 .. p_inputs.COUNT
    LOOP
    DBMS_OUTPUT.put_line ( 'citycode = '
    || p_inputs (i).city_code
    || ' CITYDESCRIPTION = '
    || p_inputs (i).city_description
    INSERT INTO testing
    (city_code, city_description
    VALUES (p_inputs (i).city_code, p_inputs (i).city_description
    commit;
    END LOOP;
    END;
    END;
    to call that procedure ia m using this
    declare
    my_data demo_pkg.cityArray;
    begin
    my_data(1).city_code := 1234;
    my_data(1).CITY_DESCRIPTION := 10;
    my_data(2).city_code := 4567;
    my_data(2).CITY_DESCRIPTION := 20;
    my_data(3).city_code := 4321;
    my_data(3).CITY_DESCRIPTION := 30;
    demo_pkg.city_report( my_data );
    end;
    but actually the procedure (demo_pkg.city_report)is called from front end(.net).how they will call this procedure in .net invironment

    Hi,
    Your exact question has been asked before, see: http://asktom.oracle.com/pls/ask/search?p_string=How+to+pass+an+array+to+a+stored+procedure
    or do a search on this forum.
    And please use this tag => (yes, just the 4 characters forming the word 'code' between curly brackets)
    *before* and *after* your example to maintain formatting and indentation, it's hard to read now....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using JNI to pass an array of Strings to C and back from C

    I have some C code that I want to integrate with a new Java application and I need to be able to pass an array of strings to the C program and then the C program needs to be able to build an array of strings that is passed back to the Java program. I've got the first part working so that I can pass an array of strings to the C program and display them, but I can't figure out how to build the strings in C so that that when Java gets back control, it can display the strings tha were built in the C program.
    Has anyone done this? Do you have some sample code?

    I have a program which is written in C. I can give you the whole project as it is in a zip file. You'll need VC to work with it. By the way, I am using Windows for development. Should you need it, I'll mail you the same. Give me your mail address.

  • [C] Passing an array in to a function [SOLVED]

    Hello, everyone,
    I'm writing a small unit testing library for myself for various C projects I've got on the go at the moment. Right now, it just consists of one function which accepts an array of tests (structs) and runs each one. The problem is that the array seems to disappear once I pass it in to the library function.
    The library's only test code at the moment is:
    #include "test.h"
    enum TestResult testPass();
    enum TestResult testFail();
    int main()
    struct Test tests[] = {
    {"pass", testPass},
    {"fail", testFail},
    testRun(tests);
    return 0;
    enum TestResult testPass()
    return PASS;
    enum TestResult testFail()
    return FAIL;
    test.h:
    #ifndef TEST_H
    #define TEST_H
    enum TestResult
    PASS,
    FAIL,
    struct Test
    char* name;
    enum TestResult (*test)();
    void testRun(struct Test*);
    #endif /* TEST_H */
    And test.c, which compiles to libtest.so:
    #include <stdio.h>
    #include "test.h"
    #define ARRAY_LENGTH(array) ((int) (sizeof(array) / sizeof(*array)))
    void testRun(struct Test* tests)
    enum TestResult result;
    int i;
    for(i = 0; i < ARRAY_LENGTH(tests); i++)
    if((result = tests[i].test()) == PASS)
    fprintf(stderr, ".");
    else if(result == FAIL)
    fprintf(stderr, "F");
    else
    fprintf(stderr, "?");
    fprintf(stderr, "\n");
    I get a single newline as output for running the test code. (that last fprintf() call). In other words, ARRAY_LENGTH(tests) == 0.
    I've tried several different ways of making the array accessible to the library, including making an extern variable in test.h (couldn't use the automatic array sizing declaration), making a static variable in test.c and initializing it with a function (the array still disappeared), and just passing it in to the function, as shown. What am I overlooking? The way I figure, an array is a pointer, meaning they (arrays) are always passed by reference, and I can therefore declare testRun() as taking a struct Test* without any using any complicated data structures to preserve the contents and make the client interface as simple as possible.
    Last edited by Michael C. (2010-04-10 21:28:02)

    Another widely used way of doing it, without having to pass the size, is to use null-terminated arrays.
    You probably know that strings are null-terminated arrays of characters?
    Well you can do the same with arrays that you define.
    You would have something like:
    struct Test tests[] = {
    {"pass", testPass},
    {"fail", testFail},
    {NULL, NULL},
    Then instead of using the size of the array, you just loop on its elements until you have the null element, then break.
    You just have to make sure you always put this null element at the end of your arrays. And that the null element is really a null element, I mean you can choose anything but of course it shouldn't be a possible normal value of the array.

  • Passing an array argument to a function by referance

    Below is my function I want to call my function but there seems to be an error in the way I am calling it can you tell me the right syntax to use?
    The function accepts 3 arguments an array of ints, an array of booleans and an int.
    I am calling it as
    findamobileset ( citys, pointers, sizeofarrays);
    public void findamobileset (int citys[], boolean[] pointers, int sizeofarrays)
    int maxarraynumber = -1;
    int tempswap = -1 ;
    boolean runagain = false;
    for(int i = 0;i < sizeofarrays; i++){
    //if the mobile flag is pointing to the right: look at the +1 current position where on and if its bigger then make that the biggest k so far
    //ALSO check if its not pointing off the array
    if(pointers[i] == true && i !=citys[sizeofarrays] && citys[i+1] < citys[i] && citys[i] > maxarraynumber){
    maxarraynumber = citys;
    //if the mobile flag is pointing to the left: look at the +1 current position where on and if its bigger then make that the biggest k so far
    if(pointers[i] ==false && i != citys[0] && citys[i-1] < citys[i] && citys[i] > maxarraynumber){
    maxarraynumber = citys[i];
    //swap k with an ajacent integer the arrow is pointing too
    if(pointers[maxarraynumber] == true)
    tempswap = citys[maxarraynumber+1];
    citys[maxarraynumber+1] =citys[maxarraynumber];
    citys[maxarraynumber] = tempswap;
    else
    {  tempswap = citys[maxarraynumber-1];
    citys[maxarraynumber-1] =citys[maxarraynumber];
    citys[maxarraynumber] = tempswap;
    //reverse all numbers greater then k
    for(int i = 0;i < sizeofarrays; i++){
    if(citys[i] > maxarraynumber){
    if(pointers[i] == true){
    pointers[i]= false;}
    else
    pointers[i] = true;
    // print out the array
    for(int i = 0;i < sizeofarrays; i++){
    System.out.print(citys[i] + " ");
    System.out.println(" ");
    //test if theres a mobile integer left to redo it and flip the flag if there is
    for(int i = 0;i < sizeofarrays; i++){
    if(pointers[i] == true && i !=citys[sizeofarrays] && citys[i+1] < citys[i] ){
    runagain = true;
    if(pointers[i] ==false && i != citys[0] && citys[i-1] < citys[i] ){
    runagain = true;
    //recurviely call the algorithm again
    if(runagain == true){
    findamobileset ( citys, pointers, sizeofarrays);
    else
    {/terminate}

    1) There is no pass-by-reference in Java. At best, you have a reference that's passed.by-value (a copy of this reference, pointing to the same object).
    2) I won't read all of your code
    3) Which is unformatted anyway
    4) so I don't know what the error is. Maybe you care to tell me?

  • Passing array to oracle stored procedure in VC++ 2005

    Hi,
    I am try to send an array of integers to a stored procedure via ODBC 10.2.0.3 on VC++2005 enviornment. I get the below error
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'MYPROC1'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored ... Error Code = 6550
    []E R R O R
    The same code works if I use an INSERT statement.
    SQLUSMALLINT* rowsProcessed = new SQLUSMALLINT;
    RETCODE nRetCode;
    const int arraySize = 200;
    long ptrVal[arraySize];
    long ptrInd[arraySize];
    long ptrStatus[arraySize];
    for (int i = 0; i < arraySize; i++)
    ptrVal = i;
    ptrInd = 0;
    nRetCode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0);
    // assign the number of sets of parameters that are to be inserted
    nRetCode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)iSizeOfArray, 0);
    // assign an array to retrieve status info for each row of parameter values
    nRetCode =SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAM_STATUS_PTR, (SQLPOINTER)ptrStatus, 0);
    // assign a buffer to store the number of sets of parameters that have been processed
    nRetCode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, (SQLPOINTER)rowsProcessed, 0);
    nRetCode = SQLBindParameter(m_hstmt, nParamIndex, nDirection, SQL_C_LONG, SQL_INTEGER, 0, 0, ptrVal, 0, ptrInd);
    //suceeds
    SQLPrepare(m_hstmt, (SQLCHAR*)"INSERT INTO my_table VALUES (?)", SQL_NTS);
    //fails
    SQLPrepare(m_hstmt, (SQLCHAR*)"{CALL mypackage.myproc1(?)}", SQL_NTS);
    SQLExecute(m_hstmt);
    package is
    create or replace package mypackage
    as
    type mytable is table of binary_integer;
    procedure myproc1( l_tab in mytable);
    end;
    show errors
    create or replace package body mypackage
    as
    procedure myproc1( l_tab in mytable)
    as
    begin
    insert into my_table values (100);
    commit;
    FORALL i IN l_tab.first .. l_tab.last
    INSERT into my_table values( l_tab(i) );
    end;
    end;
    any ideas?

    I believe when you're doing it with an insert, you're saying "execute this insert statement a bunch of times, here's all the values in advance", which is different than passing an array to a stored procedure where you want it to execute once.
    Oracle's ODBC driver doesnt support Associative Arrays (aka index-by tables).
    Hope it helps,
    Greg

  • Pass an array of a user defined class to a stored procedure in java

    Hi All,
    I am trying to pass an array of a user defined class as an input parameter to a stored procedure. So far i have done the following:
    Step 1: created an object type.
    CREATE TYPE department_type AS OBJECT (
    DNO NUMBER (10),
    NAME VARCHAR2 (50),
    LOCATION VARCHAR2 (50)
    Step 2: created a varray of the above type.
    CREATE TYPE dept_array1 AS TABLE OF department_type;
    Step 3:Created a package to insert the records.
    CREATE OR REPLACE PACKAGE objecttype
    AS
    PROCEDURE insert_object (d dept_array);
    END objecttype;
    CREATE OR REPLACE PACKAGE BODY objecttype
    AS
    PROCEDURE insert_object (d dept_array)
    AS
    BEGIN
    FOR i IN d.FIRST .. d.LAST
    LOOP
    INSERT INTO department
    VALUES (d (i).dno,d (i).name,d (i).location);
    END LOOP;
    END insert_object;
    END objecttype;
    Step 4:Created a java class to map the columns of the object type.
    public class Department
    private double DNO;
    private String Name;
    private String Loation;
    public void setDNO(double DNO)
    this.DNO = DNO;
    public double getDNO()
    return DNO;
    public void setName(String Name)
    this.Name = Name;
    public String getName()
    return Name;
    public void setLoation(String Loation)
    this.Loation = Loation;
    public String getLoation()
    return Loation;
    Step 5: created a method to call the stored procedure.
    public static void main(String arg[]){
    try{
    Department d1 = new Department();
    d1.setDNO(1); d1.setName("Accounts"); d1.setLoation("LHR");
    Department d2 = new Department();
    d2.setDNO(2); d2.setName("HR"); d2.setLoation("ISB");
    Department[] deptArray = {d1,d2};
    OracleCallableStatement callStatement = null;
    DBConnection dbConnection= DBConnection.getInstance();
    Connection cn = dbConnection.getDBConnection(false); //using a framework to get connections
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", cn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, cn, deptArray); //I get an SQLException here
    callStatement = (OracleCallableStatement)cn.prepareCall("{call objecttype.insert_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    cn.commit();
    catch(Exception e){ 
    System.out.println(e.toString());
    I get the following exception:
    java.sql.SQLException: Fail to convert to internal representation
    My question is can I pass an array to a stored procedure like this and if so please help me reslove the exception.
    Thank you in advance.

    OK I am back again and seems like talking to myself. Anyways i had a talk with one of the java developers in my team and he said that making an array of structs is not much use to them as they already have a java bean/VO class defined and they want to send an array of its objects to the database not structs so I made the following changes to their java class. (Again hoping some one will find this useful).
    Setp1: I implemented the SQLData interface on the department VO class.
    import java.sql.SQLData;
    import java.sql.SQLOutput;
    import java.sql.SQLInput;
    import java.sql.SQLException;
    public class Department implements SQLData
    private double DNO;
    private String Name;
    private String Location;
    public void setDNO(double DNO)
    this.DNO = DNO;
    public double getDNO()
    return DNO;
    public void setName(String Name)
    this.Name = Name;
    public String getName()
    return Name;
    public void setLocation(String Location)
    this.Location = Location;
    public String getLoation()
    return Location;
    public void readSQL(SQLInput stream, String typeName)throws SQLException
    public void writeSQL(SQLOutput stream)throws SQLException
    stream.writeDouble(this.DNO);
    stream.writeString(this.Name);
    stream.writeString(this.Location);
    public String getSQLTypeName() throws SQLException
    return "DOCCOMPLY.DEPARTMENT_TYPE";
    Step 2: I made the following changes to the main method.
    public static void main(String arg[]){
    try{
    Department d1 = new Department();
    d1.setDNO(1);
    d1.setName("CPM");
    d1.setLocation("LHR");
    Department d2 = new Department();
    d2.setDNO(2);
    d2.setName("Admin");
    d2.setLocation("ISB");
    Department[] deptArray = {d1,d2};
    OracleCallableStatement callStatement = null;
    DBConnection dbConnection= DBConnection.getInstance();
    Connection cn = dbConnection.getDBConnection(false);
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", cn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, cn, deptArray);
    callStatement = (OracleCallableStatement)cn.prepareCall("{call objecttype.insert_array_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    cn.commit();
    catch(Exception e){
    System.out.println(e.toString());
    and it started working no more SQLException. (The changes to the department class were done manfully but they tell me JPublisher would have been better).
    Regards,
    Shiraz

  • Can I pass an array as an input parameter for a stored procedure on SQL Server 2000

    I am trying to pass an array to a stored procedure residing on my SQL Server 2000 database server. Is this even possible? If it is possible, what is the syntax for this?
    Any help would be greatly appreciated.
    Thanks

    I have passed arrays to and from a database using SQL and ActiveX, including to and from stored procedures, but I cannot recall the precise method used to do so. If memory serves, everything is in the form of a string. You need to do a lot of parsing and 'unparsing' to get this data into your stored procedure.
    You are left with a couple of options to get your data to the stored procedure. I recommend using SQL in LabVIEW wherever possible as it saves the amount of external code calls (and believe me, calling ActiveX procedures developed by someone else in Visual Basic is NOT much fun at all...). You can either send the array and other data to the stored procedure (you will find the syntax in the SQL references in LabVIEW help under SQL), or you can send
    the array to the database, and have the database then act upon the array.
    I strongly recommend making routines (subVIs) to handle these operations.
    Sorry I don't have the syntax, I don't have SQL installed on this machine. If you can't find the syntax in the help, please post here again.
    -Mike Du'Lyea

  • Passing an array as parameter from java (java controls) to stored procedure

    Hi,
    I'm using java controls (BEA Weblogic Workshop 8.1) to call a stored procedure and send an array as a parameter to the stored procedure from java. The following code below throws an exception "Fail to convert to internal representation".
    Java code
    import com.bea.control.DatabaseControl.SQLParameter;
    // Here i create the java array
    int[] javaArray={12,13,14};
    //The code below is used to create the oracle sql array for the procedure
    SQLParameter[] params = new SQLParameter[1];
    Object obj0=javaArray;
    params[0] = new SQLParameter(obj0, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
    // the code below calls the testFunc method in OJDBCtrl.jcx file
    String succ= dbControl.testFunc(params);
    OJDBCtrl.jcx
    * @jc:sql statement="call CMNT_TST_PROC(?))"
    String testFunc(SQLParameter[] param);
    The stored procedure used:
    TYPE SL_tab IS TABLE OF number INDEX BY PLS_INTEGER;
    Procedure cmnt_tst_proc (cmnt_tst sl_tab);
    Procedure cmnt_tst_proc (cmnt_tst sl_tab) is
    BEGIN
    dbms_output.put_line('Hello');
    END;
    I am getting the following exception
    Failure=java.sql.SQLException: Fail to convert to internal representation: [I@438af4 [ServiceException]>
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
    at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:861)
    at oracle.sql.ARRAY.toARRAY(ARRAY.java:210)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7768)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7449)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7837)
    at oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4587)
    at weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:244)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl._setParameter(DatabaseControlImpl.jcs:1886)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.getStatement_v2(DatabaseControlImpl.jcs:1732)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.invoke(DatabaseControlImpl.jcs:2591)
    at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:249)
    at com.bea.wlw.runtime.jcs.container.JcsContainer.invoke(JcsContainer.java:85)
    at com.bea.wlw.runtime.core.bean.BaseContainerBean.invokeBase(BaseContainerBean.java:224)
    at com.bea.wlw.runtime.core.bean.SLSBContainerBean.invoke(SLSBContainerBean.java:109)
    at com.bea.wlwgen.StatelessContainer_ly05hg_ELOImpl.invoke(StatelessContainer_ly05hg_ELOImpl.java:153)
    Can you please let me know, what i'm doing wrong and how i can pass an array to a procedure/function using java controls.
    Any help will be highly appreciated.
    Edited by: user12671762 on Feb 24, 2010 5:03 AM
    Edited by: user9211663 on Feb 24, 2010 9:04 PM

    Thanks Michael.
    Here's the final code that i used, this might be helpful for those who face this problem
    Java Code
    // Following code gets the connection object
    InitialContext ctx = new InitialContext();
    dataSource = (DataSource)ctx.lookup("<DataSourceName>");
    conn=dataSource.getConnection();
    // Following code is used to create the array type from java
    String query="CREATE OR REPLACE TYPE STR_ARRAY AS VARRAY(3) OF NUMBER";
    dbControl.runTypeQuery(query);
    // Following code is used to obtain the oracle sql array as SQLParameter
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor("<schemaName>.STR_ARRAY", conn);
    Object[] elements = new Object[3];
    elements[0] = new Integer(12);
    elements[1] = new Integer(13);
    elements[2] = new Integer(14);
    oracle.sql.ARRAY newArray = new oracle.sql.ARRAY( desc, conn, elements);
    SQLParameter[] params = new SQLParameter[1];
    params[0] = new SQLParameter(newArray, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
    String succ= dbControl.testFunc(params);

  • Passing array args into stored procs

    Hi,
    we are trying to use TopLink to perform the mapping of a pretty large schema (200+ tables). For the purpose UI presentation we only need a few different view types, not the full information in the schema, so we want to provide specific "view objects" mapped to the DB that can be batch read by their ids.
    Defining views in the DB and mapping these to objects with TopLink doesn't work well because the views require joins and the tables are pretty large (the WHERE IN on the ids of the rows to read from the view is only applied after the entire view is instantiated).
    Alternatively, we are trying to use stored procedures that take a VARRAY or TABLE OF INTEGER as input arg and return respective cursors. However, we couldn't figure out how to pass array infos into a stored proc using TopLink. Any suggestions?
    Thx,
    Olaf

    I believe when you're doing it with an insert, you're saying "execute this insert statement a bunch of times, here's all the values in advance", which is different than passing an array to a stored procedure where you want it to execute once.
    Oracle's ODBC driver doesnt support Associative Arrays (aka index-by tables).
    Hope it helps,
    Greg

  • Urgent Pls - Using BC4J Intermedia tags

    Hi,
    I am using BC4J Intermedia tag EmbedImage to display images stored in Databases. When I try to display I get only a blank picture equivalent to the size of the image and not the image itself. The type of the image is JPG. The Image datatype in the database is ORDSYS.ORDIMAGE.
    Is it to do something with the project settings? I am using Oracle 9.0.3 version of JDeveloper.
    Any help is appreciated.
    Thanks
    Priya

    Right, that's because the oracle.ord.html.URLBuilder class builds the URL for the images by using the current JSP directory level.
    For example: if your JSP page that uses <jbo:EmbedImage> is located under http://hostname.com/contextRoot/mydir/. Then the generated URL for the image will be http://hostname.com/contextRoot/mydir/ordDeliverMedia?....
    But in web.xml, the <url-pattern> element defines the url pattern value, which by default is "/ordDeliverMedia". So the media delivery servlet only handles the requests like these: http://hostname.com/contextRoot/ordDeliverMedia?...
    So, in order to make your sample work, you need to modify the web.xml in your project. There are two alternatives:
    1. Change the <url-pattern> element to this:
    <url-pattern>/kerfisumsjon/ordDeliverMedia</url-pattern>
    This will correctly handle the JSPs located under kerfisumsjon.
    Or
    2. Change the <url-pattern> element to this:
    <url-pattern>*ordDeliverMedia</url-pattern>
    This will handle any requests for ordDeliverMedia regardless of their directory location.
    Hope this solves your problem.
    Richard

  • How do I pass an array of structs to a C function using the dll flexible prototype adapter?

    What I want to do is pass into a C dll function a variably sized Array of structs of type TPS_Data. My Code compiles but when I run it in TestStand, I get an error -17001; Program Error. "Cannot allocate 0 size buffer Error in parameter 2, 'OpenFrdData'."
    I've allocated the Array of structs, and all of the information is there before I call my function, so is it my prototype? Or am I asking too much of the DLL Flexible Prototype Adapter to pass an Array of Structs?
    I can pass in a single struct of type TPS_Data and that works, but not an array.
    Here's the relevent code:
    typedef struct TPS_DATA
    char Report_Number[256];
    char System_Name[256];
    char Open_Date[256];
    char UUT_Part_Number[256];
    char UUT_Serial_Number[256];
    char UUT_Name[256];
    char Open_Employee_Name[256];
    char Open_Employee_Number[256];
    char Close_Employee_Name[256];
    char Close_Employee_Number[256];
    char Close_Date[256];
    } TPS_Data;
    typedef struct TPS_DATA_ARRAY
    TPS_Data DataRecord;
    } TPS_DataArray;
    long __declspec(dllexport) __stdcall OpenDialog (CAObjHandle Context, TPS_DataArray *TpsData[], const char *psFaultStr, char *sComments, const int nCount);

    OK,
    I can pass the data to the DLL function, using the following types:
    typedef struct StringArrayType
    char string[10][256];
    } StringArray;
    typedef struct MultiStringArrayType
    StringArray Record[10];
    } MultiStringArray;
    void __declspec(dllexport) __stdcall ATP_TestStructPassing(StringArray Strings)
    return;
    void __declspec(dllexport) __stdcall ATP_TestMultiStructPassing(MultiStringArray *Strings)
    return;
    But when the MultiStruct function Exits, TestStand reports an Error:
    -17501 "Unexpected Operating System Error" Source: 'TSAPI'
    There doesn't seem to be a way around this, and once the error occurs, I have to force quit TestStand. I've included the sequence file, and the dll code can be compiled from the fun
    ctions shown above.
    Any thoughts on how to get around this error would be greatly appreciated.
    Attachments:
    StructArrayPassing.seq ‏16 KB

  • How to pass an array to a procedure & how to use array in IN clause in SQL

    Hi all,
    how do i pass an array of varchar2[10] in an procedure and i want to use this array in the IN caluse of the SQL statement inside the procedure. Can anyone please help me on this.
    Thanks & regards
    shyam~

    There are multiple ways. For example:
    SQL> create or replace
      2    type str10_tbl_type is table of varchar2(10)
      3  /
    Type created.
    SQL> -- Using TABLE operator
    SQL> create or replace
      2    procedure p1(
      3                 p_str10_tbl str10_tbl_type
      4                )
      5      is
      6      begin
      7          for rec in (
      8                      select  ename,
      9                              sal
    10                        from  emp,
    11                              table(p_str10_tbl)
    12                        where ename = column_value
    13                     ) loop
    14            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
    15          end loop;
    16  end;
    17  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
    KING      5000
    ALLEN     1600
    SMITH     800
    PL/SQL procedure successfully completed.
    SQL> -- Using MEMBER OF method
    SQL> create or replace
      2    procedure p1(
      3                 p_str10_tbl str10_tbl_type
      4                )
      5      is
      6      begin
      7          for rec in (
      8                      select  ename,
      9                              sal
    10                        from  emp
    11                        where ename member of p_str10_tbl
    12                     ) loop
    13            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
    14          end loop;
    15  end;
    16  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
    SMITH     800
    ALLEN     1600
    KING      5000
    PL/SQL procedure successfully completed.
    SQL> SY.

  • How do you pass an array of characters using the DLL functions

    I have exported C code into my DLL and I want to know how to pass an array of characters using LabVIEW.

    Mont;
    If you want to pass a string from LabVIEW to your dll, and you do NOT change size of the string, you can use a C String pointer (CStr), which is equivalent to (unsigned) char *.
    If you do modify size of the string, pass string as a LabVIEW structure (LStrHandle).
    The example "Passing a Variety of Data Types from DLL to LabVIEW" is an excellent starting point. Also make sure you check the manual "Using External Code in LabVIEW".
    Regards;
    Enrique
    www.vartortech.com

  • Using TestStand How I pass an array of data into a DLL (IPC3.dll) for serial communication

    I am ussing a DLL created by another party. I have the list of the C declaretions. I have been able to write a seq that can turn the comport ON/OFF or select a different port but I have not been able to send or recieved any data. I have created an array of bytes(unsigned 8-bit integers)to send and recieved data but nothing goes out or in.

    Hi Toro,
    There is an example in your \Examples\AccessingArrays\PassingArrayParametersToDLL directory that illustrates exactly how to pass TestStand arrays as arguments to dll functions. The source files for the .dll are located in the same directory.
    For more information on passing arrays as parameters to modules you should read the "DLL Flexible Prototype Adapter" section of Chatper 13 in the TestStand User Manual, and pay special attention to the subsection entitled "Array Parameters". You can access the User Manual from the TestStand Start Menu group, the TestStand Sequence Editor's Help menu, the \Doc directory, or online at the following link:
    http://digital.ni.com/manuals.nsf/websearch/50B69DA356B8D38C86256A0000660E6B?OpenDocumen
    t&node=132100_US
    Jason F.
    Applications Engineer
    National Instruments
    www.ni.com/ask

Maybe you are looking for