Using an Oracle SQL Function from JPA/TopLink

How do I get the return value from a simple (one string input parameter, returns a string) Oracle SQL Function?
Thanks!

If you mean calling a stored function in Oracle, you might try something like:
    ValueReadQuery vrq = new ValueReadQuery();
    SQLCall call = new SQLCall("begin ###res := pkg.funcInp(#inp); end;");
    vrq.setCall(call);
    Query q = em.createNativeQuery("");   // we need a Query; any query would do; we replace its contents below
    ((EJBQuery)q).setDatabaseQuery(vrq);
    q.setParameter("inp", "paramValue");
    String result = (String)q.getSingleResult();
    // #=input; ###=output; ####=input/output;
    // if you want to explicitly specify the type of an output parameter, use #### instead of ###,
    // because pure "output" parameters are always treated as java.lang.StringThis will only work in TopLink Essentials, though. I don't know how to do it in Hibernate. I have dealt mainly with TopLink, and just a little with Hibernate.
In my opinion, it's a HUGE omission not to have support for stored procedures in JPA. Virtually every project I have worked on (in two large companies) has consisted of a large portion of code in stored procedures (sometimes as much as 50% of the overall code). It's a pain to have to go through all that trouble to call the stored procedures.
Also, pay special attention to TopLink's shared L2 cache. If a stored procedure changes something in the database, TopLink won't know about it and chances are that you will end up with stale objects in the cache which you will either have to refresh, or you'd have to invalidate TopLink's cache for these objects.
Best regards,
Bisser

Similar Messages

  • How do I call pl/sql function from Toplink

    I can easily call a stored procedure from Toplink
    ====================================================
    public Collection executeSelectingStoredProcedure(StoredProcedureCall storedProcedureCall) throws DAOException
    Collection returnValue = null;
    Session session = null;
    session = this.getSession();
    returnValue = session.executeSelectingCall(storedProcedureCall);
    session.release();
    return returnValue;
    ====================================================
    The same does not work for pl/sql functions. Doesnt Toplink treat function calls as a callable statement as in JDBC?
    "select <function_name>(<arguments>) from dual" seems to be a work around. If this or using expressions is the only solution can someone please tell me the reasoning behind this shift.
    Regards
    Aamir Dehlavi

    I have the same problem.
    I have a PL/SQL function that returns a number. This function receives 2 parameters. I use StoredProcedureCall plus ValueReadQuery.
    Session aSession = SessionManager.getManager().getDefaultSession();
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("CIO_UTILS.COUNT_USER_ROLES_IN_MODULE");
    call.addNamedArgument("p_persid");
    call.addNamedArgument("p_module");
    call.addUnamedOutputArgument("rolesnum", Integer.class);
    ValueReadQuery query = new ValueReadQuery();
    //query.bindAllParameters();
    query.setCall(call);
    query.addArgument("p_persid");
    query.addArgument("p_module");
    Vector parameters = new Vector();
    parameters.addElement(persid);
    parameters.addElement(theModule);
    Integer rolesnum = (Integer) aSession.executeQuery(query,parameters);
    aSession.release();
    if(rolesnum.intValue()<=0)return false; else return true;
    However, I receive the following error:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 96:
    PLS-00312: a positional parameter association may not follow a named association
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    Call:BEGIN CIO_UTILS.COUNT_USER_ROLES_IN_MODULE(p_persid=>'SANCRA2791', p_module=>'PSL_MONITORING', ?); END;
         bind => [=> rolesnum]
    If comment the line
    "call.addUnamedOutputArgument("rolesnum", Integer.class);"
    Toplink is trating it as a procedure, and I also receive an error from PL/SQL.
    There should have to be a way of make it to receive the resoult somehow, but I do not know what.
    Thanks in advance.

  • How to call pl/sql function from element values

    EBS 11.5.10.2
    XMLP 5.6.3
    Hello,
    I noticed that the output of the rdf-to-data template conversion process makes use of an undocumented feature of data templates, and I would like to get input from experts as to which situations this feature is usable.
    The closest thing I can find in the documentation is a sample in the user guide. There is a "General Ledger Journals Data Template Example" that has a <dataStructure> section that contains <element> nodes which are NOT children of a <group> node. I can't find any explanation of this in the user guide.
    I've noticed from converted templates that in these un-grouped elements you can make calls to PL/SQL functions in the "value" attribute, like this:
    <dataStructure>
      <group name="G_LINES" source="Q_MAIN">
        <element name="Line_Num"           value="Line_Num"/>
      </group>
      <element name="C_CALCULATED_VALUE" dataType="number" value="XX_CUSTOMPROCS.SOME_FUNCTION"/>
    </dataStructure>Has anyone had any success being able to call PL/SQL functions from grouped elements? Whenever I try, it doesn't seem to work.
    When I try something like this:
    <dataStructure>
      <group name="G_LINES" source="Q_MAIN">
        <element name="Line_Num"           value="Line_Num"/>
        <element name="some_calculation"   value="XX_CUSTOMPROCS.SOME_FUNCTION"/>
        <element name="some_calculation_b" value="XX_CUSTOMPROCS.SOME_FUNCTION_B(:Line_Num)"/>
      </group>
      <element name="C_CALCULATED_VALUE" dataType="number" value="XX_CUSTOMPROCS.SOME_FUNCTION"/>
    </dataStructure>The <SOME_CALCULATION/> and <SOME_CALCULATION_B/> nodes come out empty in the output data xml file, but <C_CALCULATED_VALUE> would have a value as desired.

    ah - perfect. That makes sense. Thank you for the response!
    But what about when we need to pass parameters to those functions whos values are the results of aggregate element values?
    This happens a lot in the converted data templates, where pl/sql package functions are meant to replace formula columns from the original Oracle Report. Take this example from the conversion of ARXAGMW.rdf (Aging Report, 7 Buckets):
    (note the function call in the value of "Set_Percent_Inv_Inv" is using aggregate results from subgroups)
      <group name="G_INV_INV" dataType="varchar2" source="Q_Invoice">
        <element name="Total_Inv_Inv_Amt" function="sum" dataType="number" value="G_Invoice.C_Amt_Due_Rem_Inv"/>
        <element name="Total_Inv_Inv_B0" function="sum" dataType="number" value="G_Invoice.C_Inv_B0"/>
        <element name="Total_Inv_Inv_B1" function="sum" dataType="number" value="G_Invoice.C_Inv_B1"/>
        <element name="Total_Inv_Inv_B2" function="sum" dataType="number" value="G_Invoice.C_Inv_B2"/>
        <element name="Total_Inv_Inv_B3" function="sum" dataType="number" value="G_Invoice.C_Inv_B3"/>
        <element name="Total_Inv_Inv_B4" function="sum" dataType="number" value="G_Invoice.C_Inv_B4"/>
        <element name="Total_Inv_Inv_B5" function="sum" dataType="number" value="G_Invoice.C_Inv_B5"/>
        <element name="Total_Inv_Inv_B6" function="sum" dataType="number" value="G_Invoice.C_Inv_B6"/>
        <element name="Set_Percent_Inv_Inv"  dataType="number"  value="XX_CUSTOMPROCS.XXC_ARXAGMW.set_percent_inv_invformula(:Total_Inv_Inv_Amt, :Total_Inv_Inv_B0, :Total_Inv_Inv_B1, :Total_Inv_Inv_B2, :Total_Inv_Inv_B3, :Total_Inv_Inv_B4, :Total_Inv_Inv_B5, :Total_Inv_Inv_B6)"/>
        <element name="Sum_Percent_B0_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B0_Inv_p"/>
        <element name="Sum_Percent_B1_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B1_Inv_p"/>
        <element name="Sum_Percent_B2_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B2_Inv_p"/>
        <element name="Sum_Percent_B3_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B3_Inv_p"/>
        <element name="Sum_Percent_B4_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B4_Inv_p"/>
        <element name="Sum_Percent_B5_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B5_Inv_p"/>
        <element name="Sum_Percent_B6_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B6_Inv_p"/>
        <group name="G_Cust_Inv" dataType="varchar2" source="Q_Invoice">
          <group name="G_Site_Inv" dataType="varchar2" source="Q_Invoice">
            <group name="G_1" dataType="varchar2" source="Q_Invoice">
              <group name="G_Invoice" dataType="varchar2" source="Q_Invoice">
                <element name="C_Amt_Due_Rem_Inv" dataType="number" value="C_Amt_Due_Rem_Inv"/>
                <element name="C_Inv_B0" dataType="number" value="C_Inv_B0"/>
                <element name="C_Inv_B1" dataType="number" value="C_Inv_B1"/>
                <element name="C_Inv_B2" dataType="number" value="C_Inv_B2"/>
                <element name="C_Inv_B3" dataType="number" value="C_Inv_B3"/>
                <element name="C_Inv_B4" dataType="number" value="C_Inv_B4"/>
                <element name="C_Inv_B5" dataType="number" value="C_Inv_B5"/>
                <element name="C_Inv_B6" dataType="number" value="C_Inv_B6"/>
              </group>
            </group>
          </group>
        </group>
      </group>
      ...All of these groups and sub-groups are based on one single query, so I am not sure how I would move the function call into the query without changing the results of the function.
    In the example above, elements Sum_Percent_B0_Inv through Sum_Percent_B6_Inv grab the results of the calculation done in set_percent_inv_invformula. Here is the essence of that function:
      sum_percent_b0_inv := ROUND ((total_inv_inv_b0 / total_inv_inv_amt) * 100, 2);
      sum_percent_b1_inv := ROUND ((total_inv_inv_b1 / total_inv_inv_amt) * 100, 2);
      sum_percent_b2_inv := ROUND ((total_inv_inv_b2 / total_inv_inv_amt) * 100, 2);
      sum_percent_b3_inv := ROUND ((total_inv_inv_b3 / total_inv_inv_amt) * 100, 2);
      sum_percent_b4_inv := ROUND ((total_inv_inv_b4 / total_inv_inv_amt) * 100, 2);
      sum_percent_b5_inv := ROUND ((total_inv_inv_b5 / total_inv_inv_amt) * 100, 2);
      sum_percent_b6_inv := ROUND ((total_inv_inv_b6 / total_inv_inv_amt) * 100, 2);The only solution I can think of is to have separate queries, one for each subgroup, that do the "sum" in sql; but that seems terribly inefficient.

  • Error PLS-00306 during calling PL/SQL function from Java

    Hi all,
    I am facing a problem during call of oracle PL/SQL function from java using CallableStatement.
    I receive following error message.
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    As per above error EXPORT_HIST_ALARMS_FUNC in oracle has this signature.
    CREATE OR REPLACE FUNCTION EXPORT_HIST_ALARMS_FUNC(startDateTime VARCHAR2, endDateTime VARCHAR2, meType VARCHAR2) RETURN VARCHAR2 IS
    END EXPORT_HIST_ALARMS_FUNC;
    Above function I have called following way in java.
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(2,startDateTime);
    cStatement.setString(3,endDateTime);
    cStatement.setString(4,meType);
    cStatement.execute();
    msg = cStatement.getString(1);
    Actually above function requires three input parameters and one return parameter.
    During execution of above java code it throws SQLException and shows PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC' error.
    I have run this function directly from oracle with three parameters and run successfully and finally it returns string.
    But I am unable to figure out why it doesn't run from above java code.
    Please help regarding this.
    Thanks.
    Regards,
    Shardul Banker

    Try this:
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(1,startDateTime);
    cStatement.setString(2,endDateTime);
    cStatement.setString(3,meType);
    cStatement.execute();
    msg = cStatement.getString(1);Regards,
    Martijn Teigeler
    Edited by: mTeigeler on Oct 13, 2007 10:22 AM

  • How to call a SQL function from an XSL expression

    Hi
    In R12, in Payroll Deposit adivce/Check writer, We need to sort the earnings tag <AC_Earnings> in to two different categories as regular and other earnings. In the DB and form level of element defintiion we have a DFF which differentiates between the two kinds of earnings. But the seeded XML that is gerneated by the check writer does not have this field.
    The seeded template displays all the earnings in one column. How can we achieve this in the template without modifying the seeded XML.
    The one approach i have is to write a function and based on the return value sort the data. For this I need to know :
    1) How to call a SQL function from an XSL expression that is allowed in BI template.
    If anyone ahs faced similar requirements please share your approach.
    Thanks
    Srimathi

    Thank u..
    but i'd seen that link wen i searched in google..
    Is it possible without using any 3rd party JARs and all?
    and more importantly plz tell me what should be preferred way to call a javascript function?
    Do it using addLoadEvent() or Windows.Load etc
    OR
    Call it thru Xsl? (I donno how to do dis)
    Thanks in Advance..
    Edited by: ranjjose on Jun 3, 2008 8:21 AM

  • SP2-0575: Use of Oracle SQL feature not in SQL92 Entry Level.

    Hi,
    When I tried to login I am able to login but getting the following message:SP2-0575: Use of Oracle SQL feature not in SQL92 Entry Level.
    After loging, when I tried to "SELECT SYSDATE FROM DUAL;" I am getting the following error.
    ORA-00942: table or view does not exist
    Can somebody please help me ?

    this error may be related to glogin.sql files content, what are the outputs for these -
    SQL> describe dual ;
    Name                                      Null?    Type
    DUMMY                                              VARCHAR2(1)
    SQL> select * from dual ;
    D
    Xbest regards.

  • Sp2-0575: Use of oracle SQL feature  not in sql 92 entry level.

    Hi,
    While logging to sqlplus I'm getting the following message
    "sp2-0575: Use of oracle SQL feature not in sql 92 entry level."
    and login is successful, but I'm not able to generate next value from the sequence .
    t says no rows selected when i request
    for nextval a
    EX: select mySeq.nextval from dual; (mySeq is sequence)
    Thanx,
    Ravi.

    What has happened is that someone has enabled the Oracle feature called as FIPS flagger.
    This is a feature that Oracle provides to you if you plan to write SQL code that should be portable
    to other RDBMS systems. IF you enable this flagger and use a feature which is not in the SQL standard,
    Oracle will complain that use of this feature will make your application Oracle dependent, and you may not
    be able to run this application against any other RDBMS.
    To disable this for your SQL*Plus session do this:
    SQL> set flagger off
    SQL>
    Once you do this it will allow you to use all SQL commands including Oracle specific extensions.

  • Calling a PL/SQL function from java

    I would like to call a pl/sql function from java. My pl/sql function is taking arrays of records as parameters. How do i proceed? Which specific oracle packages do I have to import?
    Please send an example.
    TIA,
    Darko Guberina

    Documentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
    says JPublisher can publish records too.
    But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
    PACKAGE "COMPANY" AS
    type emp_rec is record (empno number, ename varchar2(10));
    type emp_list is varray(5) of emp_rec;
    type factory is record (
    name varchar(10),
    emps emp_list
    function get_factory(p_name varchar) return factory;
    END;
    then I see <unknown type or type not found> at sql or java files generated. Any ideas?

  • Calling PL/SQL function from external Java class

    I was wondering if I was able to call a pl/sql function from an external java class? If so, would you be able to tell me briefly on how to go about it. I know I can call java methods that are internally stored in the db from pl/sql, but I was hoping I could call pl/sql from external java. Thanks,
    Kelly

    Ok, I made the changes, but I'm now getting the following error:
    Error code = 1403
    Error message = ORA-01403: no data found
    ORA-06512: at "IOBOARD.GETSTATUS", line 6
    ORA-06512: at line 1
    The ora-01403 I don't understand because there is data for the name Kelly.Brace.
    ora-06512 error: at string line string.
    Here's what the code looks like after I made the changes:
    String sql = "{?=call ioboard.GetStatus(?)}";
          // create a Statement object
          myStatement = myConnection.prepareCall( sql );
          myStatement.setString( 1, "Kelly.Brace" );
          myStatement.registerOutParameter(2, java.sql.Types.LONGVARCHAR );
          // create a ResultSet object, and populate it with the
          // result of a SELECT statement
          ResultSet myResultSet = myStatement.executeQuery();
          // retrieve the row from the ResultSet using the
          // next() method
          myResultSet.next();
          // retrieve the user from the row in the ResultSet using the
          // getString() method
          String status = myResultSet.getString(1);
          System.out.println("Hello Kelly, your status is: " + status);
          // close this ResultSet object using the close() method
          myResultSet.close();Here's what the function looks like:
    CREATE OR REPLACE FUNCTION GetStatus( user_name in varchar2)
    RETURN VARCHAR2
    is
    v_status varchar2(10);
    BEGIN
    select iob_location into v_status
    from ioboard.iob_user
    where iob_username = user_name;
      RETURN( v_status);
    END;This works perfectly in the SQL Window:
    select iob_location
    from ioboard.iob_user
    where iob_username = 'Kelly.Brace';

  • How to hide system tables when using the Oracle SQL Developer?

    Hi,
    I would like to know how can I show only the tables that I created under the Tables tree? I didnt find a way to create a separate database using the Oracle Sql Developer. I see all the tables together, and would like to differentiate between different databases.
    Can anyone explain to me how to do these things?
    Thanks,

    Hi,
    I would like to know how can I show only the tables that I created under the Tables tree? Your posting is not clear,again tell something more on tables tree,what u want to achieve with it.
    How to hide system tables when using the Oracle SQL Developer? if u connected with sys, system or user with dba role then u have a privilege to see these tables,so revoke the privilege/role from ur user to view this tables if ur connected other then sys,system,
    I didnt find a way to create a separate database using the Oracle Sql Developer. DBCA is a tool for creating the new database.
    Kuljeet

  • How to find listing of modules which has used xyz PL/SQL function?

    Hi,
    How I can find the list of forms/reports which has used xyz pl/sql function?
    I want to delete a pl/sql function but before that I would like to
    make sure this function is not being used by any forms/report.
    Thanks for your help!!
    D

    There are many tools available for finding out the particular string across many forms in one shot.
    One such utility is forms apimaster.
    You can download it's 30 days free trial from the internet.

  • Oracle sql function to find VARCHAR2 data is numeric

    Hi Everyone,
    Is there oracle sql function to find whether the VARCHAR2 data is numeric?
    Thanks

    hi,
    see the below example .
    with t as
    (select '12'  as col from dual union all
    select '1 2'  as col from dual union all
    select '2 1 3'  as col from dual union all
    select 'abcde'  as col from dual union all
    select '12345'  as col from dual union all
    select '1a4A5'  as col from dual union all
    select '12a45'  as col from dual union all
    select '12aBC'  as col from dual union all
    select '12abc'  as col from dual union all
    select '12ab5'  as col from dual union all
    select '12aa5'  as col from dual union all
    select '12AB5'  as col from dual union all
    select 'ABCDE'  as col from dual union all
    select '123-5'  as col from dual union all
    select '12.45'  as col from dual union all
    select '1a4b5'  as col from dual union all
    select '1 3 5'  as col from dual union all
    select '1  45'  as col from dual union all
    select '1   5'  as col from dual union all
    select 'a  b  c  d'  as col from dual union all
    select 'a b  c   d    e'  as col from dual union all
    select 'a              e'  as col from dual union all
    select 'Steven'  as col from dual union all
    select 'Stephen'  as col from dual union all
    select '111.222.3333'  as col from dual union all
    select '222.333.4444'  as col from dual union all
    select '333.444.5555'  as col from dual union all
    select 'abcdefabcdefabcxyz'  as col from dual union all
    select 'aaa'  as col from dual union all
    select 'ddd'  as col from dual union all
    select 'ccc'  as col from dual union all
    select 'aaaaa'  as col from dual union all
    select 'aaaaaaaa'  as col from dual
    select * from t where regexp_like(col,'[1-9]')
    Result
    COL
    12
    1 2
    2 1 3
    12345
    1a4A5
    12a45
    12aBC
    12abc
    12ab5
    12aa5
    12AB5
    123-5
    12.45
    1a4b5
    1 3 5
    1  45
    1   5
    111.222.3333
    222.333.4444
    333.444.5555Thanks,
    P Prakash

  • Calling PL/SQL function from OCI?

    Hi,
    How do I execute a PL/SQL function from OCI?
    My test function:
    CREATE OR REPLACE FUNCTION GetNodeQuery(TypeId IN INTEGER) RETURN VARCHAR2 IS
    Query VARCHAR2(500);
    BEGIN
    Query := 'Select * from Logical_Name';
    RETURN Query;
    END GetNodeQuery;
    char SQL[16];
    strcpy(SQL, "GetNodeQuery(1)");
    char ColumnVariable[500];
    int VariableSize = 500;
    OCIStmtPrepare(qHandle, hError, SQL, (ub4)strlen(SQL),
    (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
    OCIDefineByPos(qHandle, &pDefine, hError, 1,
    (dvoid*)ColumnVariable, (sb4)VariableSize,
    1,(dvoid*)0, (ub2*)0, (ub2*)0,
    OCI_DEFAULT);
    OCIStmtExecute(svchp, qHandle, hError, (ub4)1, (ub4)0,
    (CONST OCISnapshot *)NULL, (OCISnapshot*)NULL,
    OCI_DEFAULT);
    On the Execute I get an error saying that ORA-00900: invalid SQL statement
    Any Help would be appreciated.
    Thank You,
    Scott Metzger
    null

    Ok, I made a mistake the
    select GetNodeQuery(1) from dual
    only works with a simple function. My real life function has a cursor via DBMS_SQL.
    I presume I would need to pass the following in my OCIStmtPrepare call:
    Define
    tmp Varchar2[256];
    begin
    tmp := GetNodeQuery(1);
    end;
    Now how do I get the value of tmp out?
    I couldn't find any examples for calling functions from OCI. If you know of some could you post the url or send them to me?
    Thanks,
    *:> Scott
    [email protected]
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Tiago Nodari ([email protected]):
    you need to modify the sqlstatement to look something like this...
    begin
    GetNodeQuery(1)
    end;
    look into the OCI documentation, there are various examples of how to do it, including, binding and defining variables...
    <HR></BLOCKQUOTE>
    null

  • Calling a pl/sql function from oracle forms

    I have written a pl/sql function in a package.
    package name- sup
    function name - func
    I have written a when-button-pressed trigger .from here I want to call this function.
    How can I do that?
    Please help..

    Thanks a lot..
    User may select 20-30 check boxes for respective name & id...then at the end , user will hit OK...from here when-button-click will call a procedure....that will update/insert/delete a table data.The procedure I have written is:-
    DECLARE
    N_CNT Number(1);
    D_SYSDATE Constant date :=sysdate;
    Begin
    select count(1)
    into N_CNT
    from dbtable L
    where L.land_id = :BLK1.LAND_ID and
    L.Operatoer_id = :BLK1.Operatoer_id and
    L.suppl_id = :BLK1.suppl_id and
    L.suppl_prof_id = :BLK1.suppl_prof_id;
    if ((N_CNT = 0) and (:LANDLISTE.state = 'A')) then
    insert into dbtable
    LAND_ID,
    STATE,
    suppl_prof_id,
    suppl_id,
    OPERATOER_ID,
    SIDST_OPD_DATO,
    SIDST_OPD_INIT
    values
    :BLK1.LAND_ID,
    'Y',
    :BLK1.suppl_prof_id,
    :BLK1.suppl_id,
    :BLK1.Operatoer_id,
    D_SYSDATE,
    :BLK1.SIDST_OPD_INIT
    elseif
    ((N_CNT>0 )and (:LANDLISTE.state = 'A')) then
    update dbtable L
    set L.SIDST_OPD_DATO = D_SYSDATE,
    L.SIDST_OPD_INIT = :BLK1.SIDST_OPD_INIT
    where L.land_id = :BLK1.LAND_ID and
    L.Operatoer_id = :BLK1.Operatoer_id and
    L.suppl_id = :BLK1.suppl_id and
    L.suppl_prof_id = :BLK1.suppl_prof_id;
    elseif ((N_CNT>0 ) and (:LANDLISTE.state = 'D')) then
    delete from dbtable L
    where L.land_id = :BLK1.LAND_ID and
    L.Operatoer_id = :BLK1.Operatoer_id and
    L.suppl_id = :BLK1.suppl_id and
    L.suppl_prof_id = :BLK1.suppl_prof_id;
    end if;
    end;
    Will it be able to load multiple data(20-30 at a time) to the table?
    Should I write anything to commit the data in the table?
    I am very new to oracle forms...please help..

  • How to passing array as parameter to oracle stored procedure from JPA

    Hi All,
    I need to call a stored proc in Oracle that accepts an array as input parameter.
    Pls let me know how should i call it from my JPA. Is this even possible without using JDBC directly?
    i keep getting the ff error:
    wrong number or types of arguments in call to ....
    my code is something like this:
    String[] myArr...
    Query query = em.createNativeQuery("BEGIN myStoredProc(:arr); END;");
    query.setParameter("arr", myArr);
    Thanks in advance.

    I also fail to get this done my code till now is:
    PLSQL Function:
    function getHtml(pWhere VARCHAR2 DEFAULT NULL,
    pColSort HTP.STRINGARRAY) return clob is
    begin
    errorhndl.Log(pMessage => 'called');
    htp.prn('das ist der test
    for i in 1 .. pColSort.count loop
    htp.p('
    pColSort['||i||']: '||pColSort(i));
    end loop;
    htp.prn('
    <table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
    htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
    htp.prn('test ende');
    return htp.gHtpPClob;
    exception
    when others then
    null;
    end getHtml;
    PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
    type STRINGARRAY is table of varchar2(256) index by binary_integer;
    JAVA DOA:
    public class ShowReportDOAImpl implements ShowReportDOA {
         private JdbcTemplate jdbcTemplate;
         private SimpleJdbcCall procShowReport;
         public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
              this.jdbcTemplate = jdbcTemplate;
              procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
              .withCatalogName("Show_Report")
              .withFunctionName("getHtml")
              .withoutProcedureColumnMetaDataAccess()
              .declareParameters(
                   new SqlParameter("pWhere", Types.VARCHAR),
                   new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
                   new SqlOutParameter("RETURN", Types.CLOB)
         public String readReport(Long id, ParameterHelper ph) {
              String[] sortCol = {"max", "michi", "stefan"};
              String pWhere = "fritz";
              MapSqlParameterSource parms = new MapSqlParameterSource();
              parms.addValue("pWhere", pWhere);
              parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
    parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
    Clob clob = procShowReport.executeFunction(Clob.class, parms);
    String clobString = "";
    try {
         System.out.println("length: "+new Long(clob.length()).intValue());
                   clobString = clob.getSubString(1, new Long(clob.length()).intValue());
              } catch (SQLException e) {
                   e.printStackTrace();
    return clobString;
    EXCEPTION IS:
    org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
         org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
         org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
         at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
         at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    root cause
    java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
         oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
         oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
         oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
         org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
         org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
         org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
         org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
         org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
         org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
         org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
         org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
         at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
         at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    Please help!!
    Please help!!

Maybe you are looking for