Call Oracle procedure with custom data type within Java and Hibernate

I have a custom date TYPE in Oracle
like
CREATE TYPE DATEARRAY AS TABLE OF DATE;
and I have a Oracle function also
like
CREATE OR REPLACE FUNCTION doesContain (list DATEARRAY, val VARCHAR2) RETURN NUMBER
IS
END doesContain;
In my Java class,
I have a collection which contain a list of java.util.Date objects
When I call Oracle function "doesContain", how to pass my java collection to this Oracle function ...
anyone can provide solutions?
Please !!!
Thanks,
Pulikkottil

Vu,
First of all you need to define your types as database types, for example:
create or replace type T_ID as table of number(5)Then you need to use the "oracle.sql.ARRAY" class. You can search this forum's archives for the term "ARRAY" in order to find more details and you can also find some samples via the JDBC Web page at the OTN Web site.
Good Luck,
Avi.

Similar Messages

  • Creating Web service for PL/SQL Procedure with Complex Data Types

    I need to created web service for PL/SQL Procedure with Complex Data types like table of records as parameters, how do we map the pl/sql table type parameters with web service, how to go about these?

    Hello,
    When you are creating a service from a Stored Procedure, the OracleAS WS tools will create necessary Java and PL wrapper code to handle the complex types (table of record) properly and make them compatible with XML format for SOAP messages.
    So what you should do is to use JDeveloper or WSA command line, to create a service from your store procedure and you will see that most of the work will be done for you.
    You can find more information in the:
    - Developing Web Services that Expose Database Resources
    chapter of the Web Service Developer's guide.
    Regards
    Tugdual Grall

  • How can take a Custom Data Type in TestStand and create a LabVIEW DataType?

    I am using LV 8.2 and TS 3.5.
    I have an existing Custom Data Type in TestStand and I want to make a LabView Type Def.  The TS DataType contains 11 elements: a Visa Resource Container of 2 elements (String, DeviceName and Number, Session), 9 Numerics and 1 String Array.  For Backwards compatability, I cannot modify the TestStand DataType.
    Thanks,
    Jean

    Hi Goldee,
    You should be able to do that. It's a two step procedure.
    1) Creates in LV a custom datatype that maps 1:1 yours TS datatype.
    2) Go in the TypePalette in the properties of yours TS Datatype and check into LV Cluster Passing Menu'. Here you can Connect a specific Field of the TS datatype to a Specific Label of the corresponding LV datatype. Once you've done it the TS datatype will result modified, I mean "starred" but the change you applied should not impact the datatype structure itself only the way you pass it to LV.
    Have a good day
    FiloP
    It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong.
    Richard P. Feynman

  • Problems with Custom Data Types when converting from TS 1.0 to 3.0.

    I am currently involved in the process of converting a test environment from TestStand 1.0, LabVIEW 5.1, and Windows NT to TestStand 3.0, LabVIEW 7.0, and Windows XP. We use a custom Operator Interface developed in LV. Based on the entered Model and Serial number, the appropriate Test Sequence is called. We also use a custom Process Model. The steps in the Test Sequence are either LV code modules or DLLs created in C++. We have LV SubVIs and C++ API functions that allow the developers of the test steps to add data to various Custom Data Types. For example, a developer may set up a test to add a note (Step.Result.Notes[x].String) when the test fails. Step.Result.Notes is a container for an array of strings. The attempt to set a note first attempts to use SetDimensions to redimension the array, then SetValString to set the value. These notes are added to the report. On the old system, everything worked fine. A note could be added to any result. On the new system, if a note is added to say the 5th result, but results 1-4 do not have a note, the test sequence ends and the Operator Interface returns to waiting for data entry (as if no test ever happened). No report is generated. The LabVIEW libraries have been modified to solve this problem by calling SetDimensions to incrementally increase the array size by one, and populating the unused TestStand array elements with an empty array of LabVIEW strings using the SetValString call . In other words, based on the previous example, if the user wants to set a note for the 5th result, the notes for results 1-4 must first be sent an empty array of strings. The report will only display the note for Result 5 (as desired). In addition to this being cumbersome, attempting to implement the same workaround in the C++ API has been unsuccessful because even though the note arrays for unwanted notes (1-4) is initialized with nothing, it is still displayed as a note (empty) on the report. If anybody knows what is wrong and what the solution is, it will be appreciated.

    Aaron,
    Thanks for your reply. I will attempt to clarify. I am working with a single step. The step calls a DLL. The DLL performs many 'checks' on the UUT (e.g. Model Number Check, Serial Number Check, Calibration Constants Check, etc.). Under the Type Palette - MyTypes.ini, we have a Step Type called TEST_DLL with a container in it called Results. In the Results container are a number of things, but I will only list the important ones:
    Notes (Array of Type 'Notes'; Type 'Notes' is a Custom Data Type (container, Type Definition)containing an array of strings called 'String')
    -Notes are generally set when on of the checks fails, otherwise no Note is set for the check.
    Val (Array of Type 'Val'; Type 'Val' is Custom Data Type (container, Type Definition) containing a Boolean called 'Boolean')
    -Val indicates whether the check passed of failed
    Pseudocode example:
    //Model Number Check
    check# = 0;
    resultBOOL = ModelNumberCheck();
    SetDimensions("Step.Result.Val", 0, "[0]", check#);
    SetValBoolean("Step.Result.Val[check#].Boolean", 0, resultBOOL);
    if(resultBOOL == FAIL)
    Note# = 0;
    SetDimensions("Step.Result.Notes", 0, "[0]", check#);
    SetDimensions(Step.Result.Notes[check#].String, 0, "[0]", Note#);
    SetValString("Step.Result.Notes[check#].String[Note#]", 0, "Model Number Check failed");
    Note# = 1;
    SetDimensions(Step.Result.Notes[check#].String, 0, "[0]", Note#);
    SetValString("Step.Result.Notes[check#].String[Note#]", 0, "Model Number = 1234");
    //Serial Number Check
    check# = 1;
    resultBOOL = SerialNumberCheck();
    SetDimensions("Step.Result.Val", 0, "[0]", check#);
    SetValBoolean("Step.Result.Val[check#].Boolean", 0, resultBOOL);
    if(resultBOOL == FAIL)
    Note# = 0;
    SetDimensions("Step.Result.Notes", 0, "[0]", check#);
    SetDimensions(Step.Result.Notes[check#].String, 0, "[0]", Note#);
    SetValString("Step.Result.Notes[check#].String[Note#]", 0, "Serial Number does not match expected");
    More Checks
    As you can see above, the "Step.Result.Val" array is redimensioned for every check. The "Step.Result.Notes" array is only redimensioned when a note needs to be added for a failing check. If the entire step executes and no check adds a note, the sequence is fine. If every check fails and therefore every check adds a note, the sequence is fine. However, if there are any gaps (e.g. check 0 adds a note, check 1 does not add a note, and check 2 tries to add a note), the sequence will stop. If I add blank notes for every check that would otherwise not have a note, the sequence completes, but the report shows the blank note.
    Also, the exact code that is causing these problems runs fine on our old systems (TestStand 1.0). I hope that I clarified the problem and thanks again for the help.

  • Call a method with complex data type from a DLL file

    Hi,
    I have a win32 API with a dll file, and I am trying to call some methods from it in the labview. To do this, I used the import library wizard, and everything is working as expected. The only problem which I have is with a method with complex data type as return type (a vector). According to this link, import library wizard can not import methods with complex data type.
    The name of this method is this:   const std::vector< BlackfinInterfaces::Count > Counts ()
    where Count is a structure defined as below:
    struct Count
       Count() : countTime(0) {}
       std::vector<unsigned long> countLines;
       time_t countTime;
    It seems that I should manually use the Call Library Function Node. How can I configure parameters for the above method?

    You cannot configure Call Library Function Node to call this function.  LabVIEW has no way to pass a C++ class such as vector to a DLL.

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Calling Stored Procedure with a DATE input parameter

    Hi. A question about Date input parameters when calling a stored procedure...
    I have a procedure that takes a DATE parameter as input. I would like that DATE value to include a Time element.
    My Application Module method takes an input parameter as java.util.Date (myParamDate) - which will preserve a time element(?).
    However when I create the CallableStatement, I'm trying to set the parameter using setDate like this (for param 5):
                st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0);           
                Connection myConn = st.getConnection();
                ArrayDescriptor myArrDesc  =  ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn);
                Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray());
                Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray());
                Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray());
                st.setString(1, repType);
                st.setObject(2, sqlParamNameArray);
                st.setObject(3,sqlParamValueArray);
                st.setObject(4,sqlFilterNameArray);
                java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime());
                st.setDate(5,myRepDate);
                System.out.println("Report Date = " + myRepDate.toString());
                st.setString(6,repUser);
                st.setString(7,repAttach);
                // set out param
                st.registerOutParameter(8, Types.NUMERIC);
                st.execute();I understand java.sql.Date does NOT include a Time element. But setDate() accepts only a java.sql.Date so my procedure parameter ends up with a zero time element.
    How do I call this procedure retaining the Time element?
    Thanks.

    It includes time element, if you want more precision go with timestamp.
    http://docs.oracle.com/javase/6/docs/api/java/sql/Date.html

  • Calling Oracle procedure with two OUT parameters

    Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
    proc_Test (p_resultset=> My_cursor)
    How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
    Thanks in adv

    Yes its possible to use multiple parameter as OUT type in procedure.
    SQL>set serveroutput on size 1000000;
    SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
      2  BEGIN
      3    OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
      4    p_num := 1;
      5  END;
      6  /
    Procedure created.
    SQL>VAR cv REFCURSOR;
    SQL>VAR num NUMBER;
    SQL>EXEC myproc(:cv, :num);
    PL/SQL procedure successfully completed.
    SQL>PRINT cv;
    SAYHELLO
    Hello Oracle
    SQL>PRINT num;
           NUM
             1
    SQL>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Problem calling stored procedure with user-defined type of input parameters

    Hi,
    I have to call a stored procedure with IN parameters, but these are user-defined types of input parameters.
    function fv_createnews (
    pit_groups in T_APPLICATION_USER_GROUPS,
    pit_documents in T_DOCUMENTS
    return varchar2;
    TYPE T_APPLICATION_USER_GROUPS IS
    TABLE OF varchar2(500)
    INDEX BY binary_integer;
    TYPE T_DOCUMENT IS record (
    name varchar2(256)
    ,url varchar2(1024)
    ,lang varchar2(30)
    ,foldername varchar2(150)
    TYPE T_DOCUMENTS IS
    TABLE OF T_DOCUMENT
    INDEX BY binary_integer;
    How can I do this using the TopLink 10.1.3 API.
    I already found following related posts, but I still can' t make it up:
    Using VARRAYs as parameters to a Stored Procedure
    Pass Object as In/Out Parameter in Stored Procedure
    Or do I have to create my own PreparedStatement for this special stored procedure call using Java and Toplink?

    As the related posts suggest, you will need to use direct JDBC code for this.
    Also I'm not sure JDBC supports the RECORD type, so you may need to wrap your stored functions with ones that either flatten the record out, or take OBJECT types.

  • Java call stored procedure with nested table type parameter?

    Hi experts!
    I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
    The following is my pl/sql code:
    create or replace package test_package as
    type row_abc is record(
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    type matrix_abc is table of row_abc index by binary_integer;
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    END test_package;
    create or replace package body test_package as
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    IS
    v_sn NUMBER(8):=0 ;
    BEGIN
    LOOP
    EXIT WHEN v_sn>5 ;
    v_sn := v_sn + 1;
    p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
    p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
    p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
    END LOOP ;
    END ;
    END test_package ;
    My java code is following, it doesn't work:
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection
    ("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
    con.setAutoCommit(false);
    CallableStatement ps = null;
    String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
    ps = con.prepareCall(sql);
    ps.setString(1,"p1");
    ps.setString(2,"p2");
    ps.setString(3,"p3");
    ps.registerOutParameter(4,OracleTypes.CURSOR);
    ps.execute();
    ResultSet rset = (ResultSet) ps.getObject(1);
    error message :
    PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Regards
    Louis

    Louis,
    If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
    create or replace type ROW_ABC as object (
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    create or replace type MATRIX_ABC as table of ROW_ABC
    /Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
    For your information, there are also code samples of how to do this on the OTN Web site.
    Good Luck,
    Avi.

  • Error while calling XQuery Function with xs:date type as Argument

    Hi,
    I have follwing function in my DataService .
    declare function tns:getXXXDetail($effectiveDate as xs:date,
    $cancelDate as xs:date) as element(ns26:XXXAccount)* {
              implCode
    declare function tns:testGetXXXDetail($searchCriteria as element(ns15:locateMemberXXXDetail))
                   as element(ns26:XXXAccount)* {
    for $Account in tns:getXXXDetail($searchCriteria/ns16:accountTypeDates/ns18:effectiveDate,
         $searchCriteria/ns16:accountTypeDates/ns18:cancelDate)
    return $Account
    I am trying to test the getXXXDetail() function from testGetXXXDetail .
    The searchCriteria is a complex type with date elements effectiveDate and cancelDate, both are optional
    When i test with effectiveDate,cancelDate elements present in $searchCriteria its working fine.
    When i remove these dates element i am getting follwing error
    "expected exactly one item, got 0 items" error
    Any Clue ?

    When i remove these dates element i am getting follwing error"expected exactly one item, got 0 items" error
    Sounds like your schema for these items indicates minOccurs="1" (or relies on that as the default).
    Edit the schema and change the definitions to be...
    <xs:element name="effectiveDate" minOccurs="0" ... />

  • Version number conflicts with NI custom data types

    Custom data type version number conflicts
    Options
    Mark as New
    Bookmark
    Subscribe
    Subscribe to RSS Feed
    Highlight
    Print
    Email to a Friend
    Report to a Moderator
    07-11-2011 08:10 AM
    I am new to Teststand software interface.  While doing my first software release under the guidance of a more experienced colleague, we discovered that Teststand will not run if it detects version number conflicts between custom data types on my machine vs. the production test machine.  I verified differences between all .seq files in my test program directory, but I did not realize that the version number difference exists in the StationGlobals.ini file, which is stored in a different location.  After discovering this, I modified the version number in one of the files.  However, two releases later, I discovered that the version number mismatches in another two files.  This raises several questions for me :
    1.  Is there a way in Teststand to view all the .seq files where a custom data type is used and then change its version number in one attempt?
    2.  Under what instances does Teststand upgrade the version number of a custom data type?
    3.  Are there any tools or scripts within Teststand that can allow the version number of custom data types to be changed in all .ini files when a difference is discovered between the current production test station settings and a new release?
    Please help.

    Have you read this?  http://zone.ni.com/devzone/cda/tut/p/id/7060
    I can tell you that your situation is not uncommon with TestStand.  The key is just doing it right the first time.  haha
    #1- I doubt that this is possible because then TestStand would have to know every location of every .seq on the machine.  You will only see it when you open the sequence file.
    #2- TestStand updates the version every time you change it.  You should get a message popup when you try to save that asks if you want to increment the version or not.  There's also a check box that says Remove Modified Mark From Types.  Look under Station Options in the File tab.  There are some settings there about Type conflicts.
    #3- http://zone.ni.com/devzone/cda/tut/p/id/7910
    http://digital.ni.com/public.nsf/allkb/4153576DA04BEB098625743D00704A09
    Hope this helps,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Custom data type version number conflicts

    I am new to Teststand software interface.  While doing my first software release under the guidance of a more experienced colleague, we discovered that Teststand will not run if it detects version number conflicts between custom data types on my machine vs. the production test machine.  I verified differences between all .seq files in my test program directory, but I did not realize that the version number difference exists in the StationGlobals.ini file, which is stored in a different location.  After discovering this, I modified the version number in one of the files.  However, two releases later, I discovered that the version number mismatches in another two files.  This raises several questions for me :
    1.  Is there a way in Teststand to view all the .seq files where a custom data type is used and then change its version number in one attempt?
    2.  Under what instances does Teststand upgrade the version number of a custom data type?
    3.  Are there any tools or scripts within Teststand that can allow the version number of custom data types to be changed in all .ini files when a difference is discovered between the current production test station settings and a new release?
    Please help.

    You'll probably get better response in the TestStand Forum instead of the LabVIEW forum.
    1.  Is there a way in Teststand to view all the .seq files where a custom data type is used and then change its version number in one attempt?
    Look at the Types Window (Ctrl-T).  This should show which version of Custom Data Types are loaded for which sequence files.
    2.  Under what instances does Teststand upgrade the version number of a custom data type?
    As far as I know, anytime you edit a custom datatype which is already in memory, TestStand will update the version of the custom data type for the currently loaded sequences.
    3.  Are there any tools or scripts within Teststand that can allow the version number of custom data types to be changed in all .ini files when a difference is discovered between the current production test station settings and a new release?
    I think you can use the Types Window to do this but I'm not positive.

  • Custom data type

    Hi, can anyone help me in creating custom data types in java?
    For example I want a data type to be able to store telephone numbers
    I dont want to use strings as they can also have a-z values and I cant use integers coz telephone numbers start with a 0.

    public class TelephoneNumber {
       private String number;
       public TelephoneNumber(String number) {
          if(number.length() != 10) throw new MonkeyPoo();
          for(char c : number.toCharArray()) {
             if(! Character.isDigit(c)) throw new Something("Blarg");
          this.number = number;
    }

  • Oracle Portal - Associated Procedures With Custom Item

    Dear Gurus,
    I need to ask a question, when i have a custom Item built using Oracle Portal 10.1.4.2.0. and we have two procedures associated with this item. I need to display this item in some place with the first procedure and in another place with the second prcoedure.
    What i want to explain is written as an example
    Custom Item Type asscoiated with two different procedures (News Custom Item Type with two different procedures "brief procedure" and "detail procedure").
    In one page i need to invoke the first procedure to display the item in Detail view and the second procedure to diplay the item in Brief view.
    How can i invoke different procedures associated with this custom item type or how can i apply different procedures on custom item type to gain different views.
    Please can help me or if you need a details i can presents more details.
    hint:
    i know something in Oracle Portal called ("Associated procedures"). and we use "related funbctions" attribute when we need to invoke a procedure to render some Custom Item Type.
    But i cannot do that and this question is very important
    Best Regards,

    I've sorted this now - silly me, I'd left a <blank line> attribute in the display properties...

Maybe you are looking for

  • IPad suddenly no longer detected by iTunes

    The cable works on my iPhone 5, so it's not the USB port nor the cable itself. My iPhone 5 and iPhone 4 are both recognized by iTunes and iPhoto, however suddenly today I couldn't sync my iPad. Any solutions, gratefully accepted. Thanks.

  • Scratches on iPod

    Any face the problem with scratches on their iPod? I had purchased my 60GB iPod Video in Jan this year. As expected, after several months of usage, the screen was scratched. This being a portable device and the fact that the screen is made of plastic

  • How do i get thunderbird to download all messages?

    how do i get thunderbird to download all messages?

  • Runtime error at SMARTFORM

    Hi, i have made a forms whch i exesute it gave me error.FORMATIN_ERROR SSFCOMPOSER MESSAGENUMBER:181 No other column available (see long text). i have created a table in the smart form,after defining the values of that TABLE.i got 5 extra CELL and i

  • Problem with Print Settings- Epson Stylus CX4200

    Hi there, I am having issues with my print settings. Firstly, when I run out of ink on a cartridges it just says "out of ink" and does not show the ink levels of the different colors. Therefore I need to replace all the colors as I do not know which