Help!! Calling PL/SQL with table of objects params

Hi JDBC experts,
This is probably a familiar problem to many of you and I was hoping you can help me.
I have a JDBC application that makes calls to a PL/SQL stored procedure that accepts and returns tables (arrays) of objects. I have an equivalent representation of these in Java (the object is a simple Java class and the array of objects is a subclass of ArrayList). The object has around 10 attributes (varchar and number) and the call typically accepts and returns between 50 and 100 objects.
I noticed that converting from one representation to the other before and after the JDBC call is very time consuming. Before calling the procedure, I need to instantiate a new oracle.sql.ARRAY and fill it with oracle.sql.STRUCT equivalents for each object in my ArrayList. After the procedure call returns, I need to instantiate a new ArrayList and fill it with my Java object representation for each oracle.sql.STRUCT in the returned oracle.sql.ARRAY. Given the # of objects returned and the size of each object, this causes performance degradation.
Is there any way I can avoid the above conversion overhead? I was reading somewhere about jpub and CustomDatum. I tried it out but the code that sqlj generated looked rather complex - but if this is the recommended approach, I can follow that.
Also, are there any java code examples for dealing with table of (non-scalar) objects with CustomDatum? I saw some code for using CustomDatum with single objects but not with a table of objects.
Your help is much appreciated!
Thanks,
Niranjan

I would do it like this :
- use existsNode function in the filter predicate to look for candidate rows regardless of the number of occurrences of target nodes in the document
- use XPath predicates on attributes to restrict target nodes
SQL> create table temp1 of xmltype;
Table created
SQL>
SQL> insert into temp1 values(xmlparse(document
  2  '<soc id="2">
  3   <listsectii>
  4    <sectie cods="4">
  5     <prodv codp="2" cant=""></prodv>
  6    </sectie>
  7    <sectie cods="5">
  8     <prodv codp="8"></prodv>
  9    </sectie>
10    <sectie cods="6">
11     <prodv codp="2"></prodv>
12    </sectie>
13   </listsectii>
14  </soc>'));
1 row inserted
SQL>
SQL> update temp1
  2  set object_value =
  3      updateXML( object_value
  4               , '/soc/listsectii/sectie[@cods="4"]/prodv[@codp="2"]/@cant'
  5               , 'new_cant' )
  6  where existsNode( object_value
  7                  , '/soc/listsectii/sectie[@cods="4"]/prodv[@codp="2"]' ) = 1
  8  ;
1 row updated
SQL> select * from temp1;
SYS_NC_ROWINFO$
<soc id="2">
  <listsectii>
    <sectie cods="4">
      <prodv codp="2" cant="new_cant"/>
    </sectie>
    <sectie cods="5">
      <prodv codp="8"/>
    </sectie>
    <sectie cods="6">
      <prodv codp="2"/>
    </sectie>
  </listsectii>
</soc>
Of course, that implies there's already an existing "cant" attribute (not the case in your samples).
If you actually need to create one, then you must use insertChildXML() instead.

Similar Messages

  • Calling a BAPI with Table parameters in BRFplus

    Hi,  BRFplus experts...
    How can we configure a  BAPI "Changing Table" parameter  when it's called form a "Call Procedure" action in BRFplus?
    We'd like to use a BAPI  (i.e. BAPI_REQUEST_CREATE) to create a REQUEST in BRFplus. We're using Call Type "Function Module" in a "Call Procedure" Action Type.
    Importing parameters are working properly, we've set Direct Values, Context Param or expressions.... like always in BRFplus...
    Problem arises when we'd need to"feed" values in a Table in the FM; i.e. REQUESTITEMIN in the mentioned BAPI (FM)...
    ...only "Context Parameter" appears, and after creating them and updating the values , no values are sent to the FM ....(already checked with debugging...)   The REQUEST ITEM is mandatory in the standard object....
    So, if anyone could give us any clue, it will be appreciated....
    Thanks in advance....

    Hi, Carsten
    Many thanks for your reply.
    We've alredy debugged the coding, but still not found why parameters are not passed....
    If we try to test another "wrapper" FM the problen will persist if it contains "TABLE" optional parameters...We couldn`t find the way to manage them in BRF+......
    Parameter "Source Table for Column Update" ....    appears after selecting the parameter REQUESTITEMIN in the list of the "Add Parameter" button  and we do'nt know how can we manage it...
    In the field of the component name REQUESTITEMIN we've already assign values for ALL fields, with "context Parameters.", but we don't really understand why the BRFplus does not allow to assign Direct values or expressions like in the importing parameters.....
    We couldn't find any example in BRF with "Tables" parameters feeded.......
    Notes are already checked deeply....(we're in NW 702 SP 10....)
    Kind regards

  • JCA IConnection call to BAPI with table in table as import and export param

    Is it possible to call a BAPI with a table in table as import and export data?
    Please give small code example if this is possible.
    Thanks in advance.

    Inner tables can be handled with:
    IRecordSet innerTable = (IRecordSet)outerTable.getObject("INNER_TABLE");

  • SQLJ calling PL/SQL with records and tables as parameters

    Has anyone used sqlj to to call procedures with records and
    tables as IN, OUT, or INOUT as parameters? If so how do you
    assign values to the IN parameter in the record/tables, and get
    values out of the record/table when it is passed back? Might
    anyone have any syntax?
    null

    One thing I forgot to mention: If you're an 8i client, then in
    8.1.6 you'll be able to use JPublisher to solve this problem,
    since it'll generate these wrappers for you.
    Pierre
    Oracle Product Development Team wrote:
    : Hi,
    : The key issue is that no part of Oracle code except PL/SQL is
    : aware of the PL/SQL Record types and PL/SQL "index-by" table
    : types.
    : So the only way to call a PL/SQL procedure with args of a
    RECORD
    : or "index-by" table types is from another PL/SQL routine.
    : In most cases, it's possible to work-around this by wrappering
    : your PL/SQL method with another which doesn't have this issue.
    : For example, if you're trying to call procedure proc01 in:
    : package pack01 is
    : type rec01 is record(n1 number, d1 date);
    : procedure proc01 (r rec01);
    : end;
    : you can create a wrapper method:
    : package pack01_wrapper is
    : procedure proc01_wrapper (n1 number, d1 date);
    : end;
    : package body pack01_wrapper is
    : procedure proc01_wrapper (n1 number, d1 date) is
    : r pack01.rec01;
    : begin
    : r.n1 := n1;
    : r.d1 := d1;
    : pack01.proc01;
    : end;
    : end;
    : If you're a 7.3 client, that's about all you can do. The Fix
    was
    : introduced in 8.0, where new structured types (ADT's) and new
    : table types (VARRAY's and Nested tables) were introduced. So
    if
    : you're an 8.0 client, your 'wrapper' package could use an ADT
    : which has the same attributes as the record, rather than
    : 'exploding' the record into its individual components as I
    showed
    : above.
    : Hope this helps!
    : Pierre
    : Thomas Richardson (guest) wrote:
    : : Has anyone used sqlj to to call procedures with records and
    : : tables as IN, OUT, or INOUT as parameters? If so how do you
    : : assign values to the IN parameter in the record/tables, and
    get
    : : values out of the record/table when it is passed back? Might
    : : anyone have any syntax?
    : Oracle Technology Network
    : http://technet.oracle.com
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Calling Stored Procedure with table type as In parameter from Java

    Hi Everyone,
    Can anyone help me with the sample code to call a stored procedure having input parameter of Table type (consisting of multiple fields) from Java. This job is currently being done by a BPEL process.
    We want to implement the same using Java.
    Any sample code will be really helpful.
    Thanks & Regards,
    Vikas

    To start using a blob you have to insert it into the database and then get it back. Sounds weird but that is how it is. Here is a very simple program to do this:
    #include<occi.h>
    #include <iostream>
    using namespace oracle::occi;
    using namespace std;
    int main()
      try
        Environment *env = Environment::createEnvironment(Environment::OBJECT);
        Connection *conn = env->createConnection("hr","hr","");
        string stmt1 = "insert into blob_tab values (:1) ";
        string stmt2 = "select col1 from blob_tab";
        Blob blob(conn);
        blob.setEmpty(conn);
        Statement *stmtObj = conn->createStatement(stmt1);
        stmtObj->setBlob(1,blob);
        stmtObj->executeUpdate();
        conn->commit();
        Blob blob1(conn);
        Statement *stmtObj2 = conn->createStatement(stmt2);
        ResultSet *rs = stmtObj2->executeQuery();
        while(rs->next())
         blob1 = rs->getBlob(1);
        string stmt3 = "begin my_proc(:1) ;end;";
        Statement *stmtObj3 =  conn->createStatement(stmt3);
        stmtObj3->setBlob(1,blob1);
        stmtObj3->executeUpdate();
      catch (SQLException e)
        cout << e.getMessage();
      /* The tables and procedure are primitive but ok for demo
        create table blob_tab(col1 blob);
        create or replace procedure my_proc(arg in blob)
        as
        begin
         -- just a putline here. you can do other more meaningful operations with the blob here
          dbms_output.put_line('hello');
       end;
    }Hope this helps.
    Thanks,
    Sumit

  • Call a function with tables in a FORM

    Hi all,
    I am currently willing to create a FORM that would call a function (which has a table in its parameters).
    In the form, I modify the fields of this table, and then I call the function.
    I put the table in the FORM parameters (either 'USING' or 'TABLES').
    Problem is: the syntax check keeps on telling me that my internal table is not correctly defined (missing the statement 'OCCURS 0') and won't compile.
    I tried to add this statement 'OCCURS 0', even 'WITH HEADER LINE', but I cannot make it work.
    Can anyone help ?
    Thx a lot.
    Isa.

    Hi,
    Declare a Ztable inside the form of the type declared in the FM with a header line.Assign the fields that u require to pass through the table and append to this Ztable.
    Now pass this Ztable to the parameters of the FM.
    This should help u out...
    Mark useful answers...

  • Want to create dynamic SQL with table join

    I want to create a dynamic SQL query so that the user can enter any two table names on the selection screen and two field names that he wants to join. After which i should be able to dynamically generate the SQL (native or open) and show the result as report. I have already read the forum threads and know how to create dynamic SQL for single table, what i m struggling with is how to do inner join. I know i can use nested select but that will make the query very slow because i want to extend it to more than 2 tables later.
    Will give points to useful answer for sure, thanks for reading.

    Hi,
    Following is a piece of code which I have used in my program.
    DATA: ws_flds(72)   TYPE c.
    DATA: ftab  LIKE TABLE OF ws_flds.
    ws_flds = 'rbukrs rprctr racct ryear '.
      APPEND ws_flds TO ftab.
       SELECT (ftab)
        INTO CORRESPONDING FIELDS OF TABLE it_grp_glpca
        FROM glpca FOR ALL ENTRIES IN i_cert_item
        WHERE kokrs = c_kokrs
            AND rldnr = '8A'
            AND rrcty IN ('0','2')
            AND rvers  = '000'
            AND rbukrs = i_cert_item-bukrs
            AND ryear  = p_ryear
            AND rprctr = i_cert_item-prctr
            AND racct  = i_cert_item-saknr
            AND ( poper BETWEEN '001' AND ws_poper )
            AND aufnr IN s_aufnr
            AND kostl IN s_kostl
            AND rfarea IN s_fkber
            AND rmvct IN s_rmvct
            AND sprctr IN s_sprctr
            AND ( racct BETWEEN c_low AND c_high ).
    You can now pass your table name as (p_table) or append fieldnames to the internal table (ftab). if it is join then you can append this table like abukrs asaknr..etc.
    Regards
    Subramanian

  • Error while calling EJB with a heavyweight Object Parameter

    Hi Everybody,
    I am getting the following Error when i call a EJB with a heavyweight Object Parameter in Sun ONE Application Server 7.0.0_04.
    [03/Jun/2005:13:40:39] WARNING ( 2484): CORE3283: stderr: org.omg.CORBA.BAD_PARAM: java.util.PropertyResourceBundle vmcid: OMG minor code: 6 completed: Maybe
    [03/Jun/2005:13:40:39] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.util.Utility.throwNotSerializableForCorba(Utility.java:1018)
    [03/Jun/2005:13:40:39] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:691)
    [03/Jun/2005:13:40:39] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
    [03/Jun/2005:13:40:39] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
    [03/Jun/2005:13:40:39] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:526)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1062)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream.write_value(CDROutputStream.java:259)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.corba.TCUtility.marshalIn(TCUtility.java:136)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.corba.AnyImpl.write_value(AnyImpl.java:599)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_any(CDROutputStream_1_0.java:538)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream.write_any(CDROutputStream.java:233)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.ShutdownUtilDelegate.writeAny(ShutdownUtilDelegate.java:196)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at javax.rmi.CORBA.Util.writeAny(Util.java:78)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.write_Array(ValueHandlerImpl.java:446)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:134)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:916)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:651)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream.write_value(CDROutputStream.java:263)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:685)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.OutputStreamHook.defaultWriteObject(OutputStreamHook.java:129)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at java.util.Vector.writeObject(Vector.java:1017)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.writeObject(Native Method)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.invokeObjectWriter(IIOPOutputStream.java:560)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:523)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1062)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:651)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream.write_value(CDROutputStream.java:263)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:685)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:745)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:167)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:526)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:123)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:136)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:116)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:1082)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.iiop.CDROutputStream.write_value(CDROutputStream.java:259)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.copyObjects(Util.java:440)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at javax.rmi.CORBA.Util.copyObjects(Util.java:296)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.hrsystem.ejb._HRSystem_Stub.get(Unknown Source)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.transaction.AddressType.submitAddressChange(Unknown Source)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.transaction.AddressType.submitToSAP(Unknown Source)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.mydata.servlet.MyDataConfirmationServlet.processServlet(Unknown Source)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.core.servlet.EnetBaseHttpServlet.service(Unknown Source)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    [03/Jun/2005:13:40:40] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at java.security.AccessController.doPrivileged(Native Method)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:158)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr: java.rmi.UnexpectedException: java.io.IOException: Serializable readObject method failed internally
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:370)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at javax.rmi.CORBA.Util.wrapException(Util.java:277)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.hrsystem.ejb._HRSystem_Stub.get(Unknown Source)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.transaction.AddressType.submitAddressChange(Unknown Source)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.transaction.AddressType.submitToSAP(Unknown Source)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.mydata.servlet.MyDataConfirmationServlet.processServlet(Unknown Source)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.mot.hris.core.servlet.EnetBaseHttpServlet.service(Unknown Source)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at java.security.AccessController.doPrivileged(Native Method)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:158)
    [03/Jun/2005:13:40:41] WARNING ( 2484): CORE3283: stderr:      at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
    Can someone please help to solve this.
    Regards,
    Sunil

    Unfortunately there's not really enough information for anyone to help you much. I can tell you've hit an EOF Exception, but that's about it.
    What exactly do you mean by a heavyweight object parameter? Do you mean a large (in memory size) object?
    Without any knowledge of your application, I'd probably start by changing your ejb method to do nothing. That should tell you at least whether it's the serialization of the parameter that's the issue or not. Narrow it down from there.
    If you need more help, printing the entire stack trace of the EOFException and posting it here would be helpful.
    -- Rob

  • Help me in tab strip with table control

    hi,
    can any body give me the idea regarding my requirment please urgent.
      my requirment is i created tab strip in main screen (111) and i created table control in subscreen (12).and i created one parameters with gui screen.if i execute that selection-screen it call tab strip .i am getting.but my requrment is when i execute selection-screen by default it will call tab strip with table data (recards) in to the table control fields which is in display mode.
    please help me urgent.
    with warm regards.
    khadar.

    yes u can create it.
    This is a sample program to create a tabstrip.
    SELECTION-SCREEN BEGIN OF SCREEN 500 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
    PARAMETERS: USER(10) TYPE c,
                PWD(10) TYPE c.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN END OF SCREEN 500.
    SELECTION-SCREEN BEGIN OF SCREEN 600 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-010.
    PARAMETERS: BUSNO(10) TYPE c,
                BUSNAME(10) TYPE c.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN END OF SCREEN 600.
    SELECTION-SCREEN BEGIN OF SCREEN 700 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-010.
    PARAMETERS: TNO(10) TYPE c,
                TNAME(10) TYPE c.
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN END OF SCREEN 700.
    SELECTION-SCREEN: BEGIN OF TABBED BLOCK sub FOR 10 LINES,
                        TAB (10) LOGIN USER-COMMAND LOGIN,
                        TAB (10) BUS USER-COMMAND BUS,
                        TAB (10) TRAIN USER-COMMAND TR,
                      END OF BLOCK sub.
    INITIALIZATION.
    LOGIN = 'LOGIN'.
    BUS = 'BUS'.
    TRAIN = 'TRAIN'.
    SUB-DYNNR = 500.
    SUB-PROG = SY-REPID.
    AT SELECTION-SCREEN.
    CASE SY-UCOMM                  .
    WHEN 'LOGIN'.
         SUB-DYNNR = 500.
    WHEN 'BUS'.
         SUB-DYNNR = 600.
    WHEN 'TR'.
         SUB-DYNNR = 700.
    ENDCASE.

  • Dynamic SQL : passing table name as parameter

    Hi
    I have a SQL query (a store procedure )  that i want to convert to PLSQL
    This is a part of my SQL query that i am trying to to find a solution for it, because i cant convert it to oracle :
    DECLARE lookupTableRow CURSOR FOR
      SELECT TableName FROM SYS_LookUpTable
      OPEN lookupTableRow
      FETCH NEXT FROM lookupTableRow INTO @tableName
      WHILE @@FETCH_STATUS=0
      BEGIN
      SET @sql='SELECT * FROM '+@tableName
    EXECUTE sp_executesql @sql
      IF @counter=0
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName)
      END
      ELSE
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table'+CONVERT(NVARCHAR(10),@counter), @tableName)
      END
      SET @counter=@counter+1
      FETCH NEXT FROM lookupTableRow INTO @tableName
      END
      CLOSE lookupTableRow
      DEALLOCATE lookupTableRow
    As i understand i can't use ORACLE dynamic sql (execute immediate) when the table name is a parameter
    Furthermore when i execute this dynamic query in my SQL store procedure each SELECT statement return me as a result the relevant table rows , those result are different in each loop .
    So i cant do this too with ORACLE dynamic sql .
    Please advice for any solution
    * how can i use dynamic sql with table name as parameter ?
    * how can i use a "dynamic" cursor, in order to be able to display the dynamic results ?
    Thanks for the advice

    Hi,
    b003cf5e-e55d-4ff1-bdd2-f088a662d9f7 wrote:
    Hi
    I have a SQL query (a store procedure )  that i want to convert to PLSQL
    This is a part of my SQL query that i am trying to to find a solution for it, because i cant convert it to oracle :
    DECLARE lookupTableRow CURSOR FOR
      SELECT TableName FROM SYS_LookUpTable
      OPEN lookupTableRow
      FETCH NEXT FROM lookupTableRow INTO @tableName
      WHILE @@FETCH_STATUS=0
      BEGIN
      SET @sql='SELECT * FROM '+@tableName
    EXECUTE sp_executesql @sql
      IF @counter=0
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName)
      END
      ELSE
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table'+CONVERT(NVARCHAR(10),@counter), @tableName)
      END
      SET @counter=@counter+1
      FETCH NEXT FROM lookupTableRow INTO @tableName
      END
      CLOSE lookupTableRow
      DEALLOCATE lookupTableRow
    As i understand i can't use ORACLE dynamic sql (execute immediate) when the table name is a parameter
    Furthermore when i execute this dynamic query in my SQL store procedure each SELECT statement return me as a result the relevant table rows , those result are different in each loop .
    So i cant do this too with ORACLE dynamic sql .
    Please advice for any solution
    * how can i use dynamic sql with table name as parameter ?
    * how can i use a "dynamic" cursor, in order to be able to display the dynamic results ?
    Thanks for the advice
    I have a SQL query (a store procedure )  that i want to convert to PLSQL
    I doesn't help when you use one term to mean another thing.
    SQL is a language used in both Oracle and other products, such as Microsoft's SQL Server. I don't know much about SQL Server, but Oracle (at least) doesn't support stored procedures in SQL itself; they have to be coded in some other language, such as PL/SQL.  
    As i understand i can't use ORACLE dynamic sql (execute immediate) when the table name is a parameter
    If the table name is a parameter (or only known at run-time for any reason), that's exactly the kind of situation where you MUST use dynamic SQL.
    The number of columns that a query produces (and their datatypes) is fixed when you compile a query, whether that query is dynamic or not.  If you have multiple queries, that produce result sets with different numbers of columns, then you can't combine them into a single query.  The best you can do with one query is to add NULL columns to some of the queries so they all produce the same number of columns.
    If you're just displaying the results, there might not be any reason to combine separate result sets.  Just display one result set after another.
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Errer when, Call from java to pl sql procedure with table out parameter

    Hi ,
    Please help me ? It's urgent for me .....
    My Oracle Code is like this ,
    CREATE TABLE TEST_TABLE ( DATE1 DATE, VALUE_EXAMPLE VARCHAR2(20 BYTE), VALUE2_EXAMPLE VARCHAR2(20 BYTE), VALUE3_EXAMPLE NUMBER ); CREATE OR REPLACE TYPE TONERECORDTEST AS OBJECT ( DATE1 DATE, VALUE_EXAMPLE VARCHAR2(20), VALUE2_EXAMPLE VARCHAR2(20), VALUE3_EXAMPLE NUMBER ); CREATE OR REPLACE TYPE TTESTTABLE IS TABLE OF TONERECORDTEST; CREATE OR REPLACE PACKAGE test_collection_procedures AS PROCEDURE testCallProcedureFromJava(start_time IN DATE, end_time IN DATE, table_data OUT TTesttable); END test_collection_procedures; / CREATE OR REPLACE PACKAGE BODY test_collection_procedures AS PROCEDURE testCallProcedureFromJava(start_time IN DATE, end_time IN DATE, table_data OUT TTesttable) IS BEGIN SELECT TONERECORDTEST(date1, value_example, value2_example, value3_example) BULK COLLECT INTO table_data FROM TEST_TABLE WHERE DATE1>=start_time AND DATE1<=end_time; END testCallProcedureFromJava; END test_collection_procedures;
    And my Java Code is like
    import java.sql.Connection; import java.sql.DriverManager; import oracle.jdbc.OracleCallableStatement; import oracle.jdbc.OracleTypes; import oracle.sql.ARRAY; import oracle.sql.ArrayDescriptor; import oracle.sql.STRUCT; import oracle.sql.StructDescriptor; public class testPLCollectionType { public static void main(java.lang.String[] args) { try{ //Load the driver Class.forName ("oracle.jdbc.driver.OracleDriver"); // Connect to the database Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@serverbd:1521:squema1","user", "password"); // First, declare the Object arrays that will store the data (for TONERECORDTEST OBJECT TYPE) Object [] p2recobj; Object [] p3recobj; Object [] p4recobj; // Declare the Object Arrays to hold the STRUCTS (for TTESTTABLE TYPE) Object [] p2arrobj; // Declare two descriptors, one for the ARRAY TYPE // and one for the OBJECT TYPE. StructDescriptor desc1=StructDescriptor.createDescriptor("TONERECORDTEST",conn); ArrayDescriptor desc2=ArrayDescriptor.createDescriptor("TTESTTABLE",conn); // Set up the ARRAY object. ARRAY p2arr; // Declare the callable statement. // This must be of type OracleCallableStatement. OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall("{call test_collection_procedures.testCallProcedureFromJa va(?,?,?)}"); // Declare IN parameters. Realize that are 2 DATE TYPE!!! Maybe your could change with setDATE ocs.setString(1,"01-JAN-04"); ocs.setString(2,"10-JAN-05"); // Register OUT parameter ocs.registerOutParameter(3,OracleTypes.ARRAY,"TTESTTABLE"); // Execute the procedure ocs.execute(); // Associate the returned arrays with the ARRAY objects. p2arr = ocs.getARRAY(3); // Get the data back into the data arrays. //p1arrobj = (Object [])p1arr.getArray(); p2arrobj = (Object [])p2arr.getArray(); System.out.println("Number of rows="+p2arrobj.length); System.out.println("Printing results..."); for (int i=0; i<p2arrobj.length; i++){ Object [] piarrobj = ((STRUCT)p2arrobj).getAttributes();
    System.out.println();
    System.out.print("Row "+i);
    for (int j=0; j<4; j++){
    System.out.print("|"+piarrobj[j]);
    }catch (Exception ex){
    System.out.println("Exception-->"+ex.getMessage());
    Actually when i running the java program it is showing error
    Exception-->ORA-06550: line 1, column 58:
    PLS-00103: Encountered the symbol "VA" when expecting one of the following:
    := . ( @ % ;
    The symbol ":=" was substituted for "VA" to continue.
      I am not getting the error .Please help me out Dhabas Edited by: Dhabas on Jan 12, 2009 3:49 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    // Declare the callable statement.
    // This must be of type OracleCallableStatement.
    ..."{call test_collection_procedures.testCallProcedureFromJa va(?,?,?)}");Looks like Ja divorced va.

  • Help with constraints on object relational tables

    Hi
    I am looking to create an object relational database with a check constraint on the relationships. For example:
    * I have table called person_tab which is a table of person_t type.
    * Person_t type is inherited by the manager_t type and the applicant_t type.
    * I have a second table called interview_tab of interview_t type.
    * The interview table has two columns (manager and appilcant) that are scope restrained to the person table.
    * I would also like to put check constraints on these columns to say:
    ----- Manager: check the person_number is less than 20000
    ----- Applicant: check the person_number is greater than 19999
    Can anyone tell me if this is possible and if so how can it be done?
    Thanks in advance
    Stephen

    You have circular dependencies (manager_t depends upon interview_list_t depends upon interview_t depends upon manager_t) which I don't think is a good idea. But then that's probably just my old-fashioned relational head baulking at this new-fangled OO way of looking at data models. However, my experience with using types and subtypes in Oracle does teach me that this is a complete pain in the neck, because it makes changing your Type definitions a very awkward process.
    am I right in saying I cannot use the check constraint?I think so. If the value range for ID is a property of being a Manager or an Applicant then properly that should be enforced by those types not by the Interview type. Then all that Interviews needs to worry about is that it gets instantiated with attributes of the correct Type.
    I've simplified your model a bit. To start with I'm going to create a single PERSONS table to store both managers and applicants...
    SQL> CREATE TYPE person_t AS OBJECT (
      2  personno NUMBER,
      3  surname VARCHAR2(30),
      4  forename VARCHAR2(30),
      5  dob DATE
      6  ) NOT FINAL;
      7  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE applicant_t UNDER person_t
      2  (qualifications varchar2(200))
      3  FINAL ;
      4  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE manager_t UNDER person_t
      2  (extension varchar2(5)) FINAL;
      3  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE interview_t AS OBJECT (
      2  interviewno NUMBER,
      3  idate DATE,
      4  itime NUMBER,
      5  interest NUMBER,
      6  is_made_by REF manager_t,
      7  attended_by REF applicant_t
      8  ) ;
      9  /
    Type created.
    SQL>
    SQL>
    SQL> CREATE TABLE persons OF person_t
      2  /
    Table created.
    SQL> CREATE TABLE interviews OF interview_t
      2  /
    Table created.
    SQL> Okay let's create some objects...
    SQL> declare
      2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
      3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
      4     intv interview_t;
      5     m_ref REF  person_t;
      6     a_ref REF person_t;
      7  begin
      8     INSERT INTO persons p VALUES mgr
      9         RETURNING REF(p) INTO m_ref   ;
    10     INSERT INTO persons p VALUES app
    11         RETURNING REF(p) INTO a_ref   ;
    12     insert into interviews
    13     values (interview_t(1001, sysdate, 45, 5, TREAT(m_ref AS REF manager_t)
            , TREAT(a_ref AS REF applicant_t)));
    14  end;
    15  /
    PL/SQL procedure successfully completed.
    SQL> SELECT i.interviewno, i.is_made_by.surname, i.attended_by.surname
      2  FROM interviews i
      3  /
    INTERVIEWNO IS_MADE_BY.SURNAME             ATTENDED_BY.SURNAME                 
           1001 RUNCITER                       CHIP                                
    SQL> Have we got integrity?
    SQL> rollback
      2  /
    Rollback complete.
    SQL>
    SQL> declare
      2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
      3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
      4     intv interview_t;
      5     m_ref REF  person_t;
      6     a_ref REF person_t;
      7  begin
      8     INSERT INTO persons p VALUES mgr
      9         RETURNING REF(p) INTO m_ref   ;
    10     INSERT INTO persons p VALUES app
    11         RETURNING REF(p) INTO a_ref   ;
    12     insert into interviews
    13     values (interview_t(1001, sysdate, 45, 5, TREAT(a_ref AS REF manager_t)
             , TREAT(m_ref AS REF applicant_t)));
    14  end;
    15  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> SELECT i.interviewno, i.is_made_by.surname, i.attended_by.surname
      2  FROM interviews i
      3  /
    INTERVIEWNO IS_MADE_BY.SURNAME             ATTENDED_BY.SURNAME                 
           1001                                                                    
    SQL> Kind of, but it's not very satisfactory. Let's use separate tables for MANAGERS and APPLICANTS...
    SQL> rollback
      2  /
    Rollback complete.
    SQL>
    SQL> CREATE TABLE managers OF manager_t
      2  /
    Table created.
    SQL>
    SQL> CREATE TABLE applicants OF applicant_t
      2  /
    Table created.
    SQL> declare
      2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
      3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
      4     intv interview_t;
      5     m_ref REF  manager_t;
      6     a_ref REF applicant_t;
      7  begin
      8     INSERT INTO managers m VALUES mgr
      9         RETURNING REF(m) INTO m_ref   ;
    10     INSERT INTO applicants a VALUES app
    11         RETURNING REF(a) INTO a_ref   ;
    12     insert into interviews values (interview_t(1001, sysdate, 45, 5, m_ref, a_ref));
    13 
    14  end;
    15  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> SELECT i.interviewno, i.is_made_by.surname, i.attended_by.surname
      2  FROM interviews i
      3  /
    INTERVIEWNO IS_MADE_BY.SURNAME             ATTENDED_BY.SURNAME                 
           1001 RUNCITER                       CHIP                                
    SQL> rollback
      2  /
    Rollback complete.
    SQL> declare
      2     mgr manager_t := manager_t(1,'RUNCITER', 'GLEN', sysdate - (42*365), 'x1234');
      3     app applicant_t := applicant_t(2,  'CHIP', 'JOE', sysdate - (38*365), 'BSc, MSc');
      4     intv interview_t;
      5     m_ref REF  manager_t;
      6     a_ref REF applicant_t;
      7  begin
      8     INSERT INTO managers m VALUES mgr
      9         RETURNING REF(m) INTO m_ref   ;
    10     INSERT INTO applicants a VALUES app
    11         RETURNING REF(a) INTO a_ref   ;
    12     insert into interviews values (interview_t(1001, sysdate, 45, 5, a_ref, m_ref));
    13 
    14  end;
    15  /
       insert into interviews values (interview_t(1001, sysdate, 45, 5, a_ref, m_ref));
    ERROR at line 12:
    ORA-06550: line 12, column 69:
    PL/SQL: ORA-00932: inconsistent datatypes: expected REF APC.APPLICANT_T got REF
    APC.MANAGER_T
    ORA-06550: line 12, column 4:
    PL/SQL: SQL Statement ignored
    SQL>I hope that's useful to you.
    Cheers, APC
    Layout of SQL*Plus session tweaked for readability
    Message was edited by:
    APC

  • Sporadically getting error "string or binary data would be truncated" in SQL server 2008 while inserting in a Table Type object

    I am facing a strange SQL exception:-
    The code flow is like this:
    .Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception})
    In the SQL Table-Valued Function, I am selecting a column (nvarchar(50)) from an existing table and (after some filtration using inner joins and where clauses) inserting the values in a Table Type Object having a column (nvarchar(50))
    This flow was working fine in SQL 2008 but now all of sudden the Insert into @TableType is throwing  "string or binary data would be truncated"  exception. 
    Insert Into @ObjTableType
    Select * From dbo.Table
    The max length of data in the source column is 24 but even then the insert statement into nvarchar temp column is failing.
    Moreover, the same issue started coming up few weeks back and I was unable to find the root cause, but back then it started working properly after few hours
    (issue reported at 10 AM EST and was automatically resolved post 8 PM EST). No refresh activity was performed on the database.
    This time however the issue is still coming up (even after 2 days) but is not coming up in every scenario. The data set, for which the error is thrown, is valid and every value in the function is fetched from existing tables. 
    Due to its sporadic nature, I am unable to recreate it now :( , but still unable to determine why it started coming up or how can i prevent such things to happen again.
    It is difficult to even explain the weirdness of this bug but any help or guidance in finding the root cause will be very helpful.
    I also Tried by using nvarchar(max) in the table type object but it didn't work.
    Here is a code similar to the function which I am using:
    BEGIN
    TRAN
    DECLARE @PID
    int = 483
    DECLARE @retExcludables
    TABLE
        PID
    int NOT
    NULL,
        ENumber
    nvarchar(50)
    NOT NULL,
        CNumber
    nvarchar(50)
    NOT NULL,
        AId
    uniqueidentifier NOT
    NULL
    declare @PSCount int;
    select @PSCount =
    count('x')
    from tblProjSur ps
    where ps.PID
    = @PID;
    if (@PSCount = 0)
    begin
    return;
    end;
    declare @ExcludableTempValue table (
            PID
    int,
            ENumber
    nvarchar(max),
            CNumber
    nvarchar(max),
            AId
    uniqueidentifier,
            SIds
    int,
            SCSymb
    nvarchar(10),
            SurCSymb
    nvarchar(10)
    with SurCSymbs as (
    select ps.PID,
                   ps.SIds,              
                   csl.CSymb
    from tblProjSur ps
                right
    outer join tblProjSurCSymb pscs
    on pscs.tblProjSurId
    = ps.tblProjSurId
    inner join CSymbLookup csl
    on csl.CSymbId
    = pscs.CSymbId 
    where ps.PID
    = @PID
        AssignedValues
    as (
    select psr.PID,
                   psr.ENumber,
                   psr.CNumber,
                   psmd.MetaDataValue
    as ClaimSymbol,
                   psau.UserId
    as AId,
                   psus.SIds
    from PSRow psr
    inner join PSMetadata psmd
    on psmd.PSRowId
    = psr.SampleRowId
    inner join MetaDataLookup mdl
    on mdl.MetaDataId
    = psmd.MetaDataId
    inner join PSAUser psau
    on psau.PSRowId
    = psr.SampleRowId
                inner
    join PSUserSur psus
    on psus.SampleAssignedUserId
    = psau.ProjectSampleUserId
    where psr.PID
    = @PID
    and mdl.MetaDataCommonName
    = 'CorrectValue'
    and psus.SIds
    in (select
    distinct SIds from SurCSymbs)         
        FullDetails
    as (
    select asurv.PID,
    Convert(NVarchar(50),asurv.ENumber)
    as ENumber,
    Convert(NVarchar(50),asurv.CNumber)
    as CNumber,
                   asurv.AId,
                   asurv.SIds,
                   asurv.CSymb
    as SCSymb,
                   scs.CSymb
    as SurCSymb
    from AssignedValues asurv
    left outer
    join SurCSymbs scs
    on    scs.PID
    = asurv.PID
    and scs.SIds
    = asurv.SIds
    and scs.CSymb
    = asurv.CSymb
    --Error is thrown at this statement
    insert into @ExcludableTempValue
    select *
    from FullDetails;
    with SurHavingSym as (   
    select distinct est.PID,
                            est.ENumber,
                            est.CNumber,
                            est.AId
    from @ExcludableTempValue est
    where est.SurCSymb
    is not
    null
    delete @ExcludableTempValue
    from @ExcludableTempValue est
    inner join SurHavingSym shs
    on    shs.PID
    = est.PID
    and shs.ENumber
    = est.ENumber
    and shs.CNumber
    = est.CNumber
    and shs.AId
    = est.AId;
    insert @retExcludables(PID, ENumber, CNumber, AId)
    select distinct est.PID,
    Convert(nvarchar(50),est.ENumber)
    ENumber,
    Convert(nvarchar(50),est.CNumber)
    CNumber,
                            est.AId      
    from @ExcludableTempValue est 
    RETURN
    ROLLBACK
    TRAN
    I have tried by converting the columns and also validated the input data set for any white spaces or special characters.
    For the same input data, it was working fine till yesterday but suddenly it started throwing the exception.

    Remember, the CTE isn't executing the SQL exactly in the order you read it as a human (don't get too picky about that statement, it's at least partly true enough to say it's partly true), nor are the line numbers or error messages easy to read: a mismatch
    in any of the joins along the way leading up to your insert could be the cause too.  I would suggest posting the table definition/DDL for:
    - PSMetadata, in particular PSRowID, but just post it all
    - tblProjectSur, in particularcolumns CSymbID and TblProjSurSurID
    - cSymbLookup, in particular column CSymbID
    - PSRow, in particular columns SampleRowID, PID,
    - PSAuser and PSUserSur, in particualr all the USERID and RowID columns
    - SurCSymbs, in particular colum SIDs
    Also, a diagnostic query along these lines, repeat for each of your tables, each of the columns used in joins leading up to your insert:
    Select count(asurv.sid) as count all
    , count(case when asurv.sid between 0 and 9999999999 then 1 else null end) as ctIsaNumber
    from SurvCsymb
    The sporadic nature would imply that the optimizer usually chooses one path to the data, but sometimes others, and the fact that it occurs during the insert could be irrelevant, any of the preceding joins could be the cause, not the data targeted to be inserted.

  • Using SQL with Nested Table

    Hi ,
    Please assist as how can we do this thing
    i have a nested table of object type
    create or replace type a1 as object
    a number,
    b varchar2(30),
    region varchar2(30)
    create type a1_array s table of a1;
    declare
    v_a1 a1;
    v_a1_array a1_array:=a1_array();
      begin
    v_a1= a1(1, '1' , 'AUS');
    v_a1_array.EXTEND;
    v_a1_array(1):=v_a1;
    v_a1= a1(2, '2' , 'AUS');
    v_a1_array.EXTEND;
    v_a1_array(2):=v_a1;
    v_a1= a1(3, '3' , 'NAM');
    v_a1_array.EXTEND;
    v_a1_array(3):=v_a1;
      end;
    Now, i have v_a1_array having 3 rows 2 with AUS region and one with NAM region.
    Using SQL can i extract only 'AUS'  rows and fetch in  ARRAY OF TYPE v_a1_array (using Where clause  and Table () functions )
    Any help will be highly appreciated. Please assist. I have oracle 11g
    Thanks

    Hi,
    GPU has already shown you how to do. I will just modify my original one:
    SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 22 22:14:42 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2     v_a1           a1;
      3     v_a1_array     a1_array := a1_array ();
      4     v_a1_array2    a1_array;
      5  BEGIN
      6     v_a1 := a1 (1, '1', 'AUS');
      7     v_a1_array.EXTEND;
      8     v_a1_array (1) := v_a1;
      9     v_a1 := a1 (2, '2', 'AUS');
    10     v_a1_array.EXTEND;
    11     v_a1_array (2) := v_a1;
    12     v_a1 := a1 (3, '3', 'NAM');
    13     v_a1_array.EXTEND;
    14     v_a1_array (3) := v_a1;
    15
    16     SELECT a1(a, b, region)
    17       BULK COLLECT INTO v_a1_array2
    18       FROM TABLE (v_a1_array)
    19      WHERE region = 'AUS';
    20
    21     FOR c1 IN (SELECT *
    22                  FROM TABLE (v_a1_array2))
    23     LOOP
    24        DBMS_OUTPUT.put_line ('A='||c1.a||', B='||c1.b||', REGION='||c1.region);
    25     END LOOP;
    26  END;
    27  /
    A=1, B=1, REGION=AUS
    A=2, B=2, REGION=AUS
    PL/SQL procedure successfully completed.
    If you consider your question answered, please mark this thread as answered.
    Regards.
    Alberto

  • Is there table type object in PL/SQL?

    Hi.
    What I'm trying to do is, according to the some conditions, aggregate data as an object type( I am not sure that there's a similar thing)
    There are 5-6 conditions. then at last join those table type object.
    FYI, Here is an example
    Company will give bonus to a person who meet these conditions
    1. Salary is less than 1000$ - salary table
    2. More than 5 persons in his family - staff table
    3. gross sale is over 10000$
    In PL/SQL Package, I'll get those data as an object type and join those object just like in-line query.
    select emp_no
    from sal_tbl , staff_tbl, sale_tbl
    where sal_tbl = staff_tbl
    and sal_tbl = sale_tbl
    In my opinion I can get employee list who get bonus. because they meet all conditions.
    Reason why bonus condition will be updated continuously. I want to make them easy to maintanence. what if I need to add new conditions. Just add a new procedure that calculate new result and pass as an table type object.
    select emp_no
    from sal_tbl , staff_tbl, sale_tbl, new_tbl*
    where sal_tbl = staff_tbl
    and sal_tbl = sale_tbl
    and sal_tbl = new_tbl*
    Is there any thing just like what I think?
    Thanks in advance
    Message was edited by: me
    allbory
    I have read Oracle user guide - Collection, Record, and Cursor. But I can't get anything that I want.
    Give me some clues

    > In PL/SQL Package, I'll get those data as an object type and join those object just like
    in-line query.
    Not the best of ideas. If I'm getting what you're saying, you want to use the following approach:
    SQL> create or replace type TStrings as table of varchar2(4000);
    2 /
    Type created.
    SQL>
    SQL>
    SQL> create or replace procedure BadIdea( collection TStrings ) is
    2 minVal string(4000);
    3 maxVal string(4000);
    4 begin
    5 -- in the procedure we now run SQLs against the collection
    6 select
    7 MIN( column_value ) into minVal
    8 from TABLE( collection );
    9
    10 select
    11 MAX( column_value ) into maxVal
    12 from TABLE( collection );
    13 end;
    14 /
    Procedure created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> -- and then we call this procedure to do our "SQL" processing for us
    SQL> declare
    2 list TStrings;
    3 begin
    4 select
    5 object_name bulk collect into list
    6 from user_objects;
    7
    8 BadIdea( list );
    9 end;
    10 /
    PL/SQL procedure successfully completed.A collection of objects resides in (non-sharable and expensive) PL/SQL memory. Running SQL, requires the PL/SQL engine copying the data to the SQL engine into a structure and format that the SQL engine will understand.
    This is slow. This is expensive. This does not scale.
    It makes little sense to copy data from the very fast and hot and good and scalable db buffer cache into an expensive memory structure in the PGA and then run SQLs against that.
    > Reason why bonus condition will be updated continuously. I want to make them easy
    to maintanence. what if I need to add new conditions. Just add a new procedure that
    calculate new result and pass as an table type object.
    The way I read your SQL, your new_tbl* requires dynamic SQL. Which means you also need to dynamically cater for the correct column names to join on, to filter on, and to select from.
    Also not the best of ideas. Dynamic SQL like that requires a lot of code to deal correctly with bind variables. Lot of exception handling as there can easily be run-time errors as the code itself that is executed in turn creates new dynamic code to execute.
    If this is to be truly dynamic, then one approach would be that each rule needs to be executable as a SQL or PL/SQL block. Each rule needs to have an input like an employee number. Each rule needs to returns a boolean like value, saying whether the rule has passed or failed.
    Only when all the rules have been passed, can the bonus be allocated.
    This will deal fine with the "dynamic rule" requirement. Performance wise and scalability wise.. it may not be the best of ideas. 10 dynamic and very slow and expensive rules, could very well be rewritten as a one very fast and very cheap static SQL statement.
    Anyway, the dynamic rule approach can look something like the following:
    SQL> create or replace type TBonusRule is object
    2 (
    3 result# char(1),
    4 member function Passed return boolean
    5 )
    6 not final;
    7 /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create or replace type body TBonusRule is
    2 member function Passed return boolean is
    3 begin
    4 return( UPPER(self.result#) = 'Y' );
    5 end;
    6 end;
    7 /
    Type body created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create or replace type TBonusSQLRule under TBonusRule
    2 (
    3 constructor function TBonusSQLRule( empNo number, sqlStatement varchar2 ) return self as result
    4 ) final;
    5 /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create or replace type body TBonusSQLRule is
    2 constructor function TBonusSQLRule( empNo number, sqlStatement varchar2 ) return self as result is
    3 begin
    4 execute immediate sqlStatement
    5 into self.result#
    6 using IN empNo;
    7
    8 return;
    9 end;
    10
    11 end;
    12 /
    Type body created.
    SQL> show errors
    No errors.
    SQL>
    SQL> set serveroutput on
    SQL> declare
    2 rule1 TBonusSQLRule;
    3 rule2 TBonusSQLRule;
    4 empNo number;
    5 begin
    6 empNo := 7369; -- we process employee 7369
    7
    8 -- we apply bonus rule 1 that check if the employee is a clerk (of course,
    9 -- we could be reading these rules from a rules table - this example simply
    10 -- creates them dynamically)
    11 rule1 := new TBonusSQLRule( empNo, 'select ''Y'' from emp where empno = :0 and job=''CLERK''' );
    12
    13 if rule1.Passed then
    14 DBMS_OUTPUT.put_line( 'Rule 1. PASSED' );
    15 else
    16 DBMS_OUTPUT.put_line( 'Rule 1. FAILED' );
    17 end if;
    18
    19 -- rule 2 can for example check if the employee has been working for at least 5 years for the
    20 -- company
    21 rule2 := new TBonusSQLRule( empNo, 'select ''Y'' from emp where empno = :0 and (SYSDATE-hiredate)>5*365' );
    22
    23 if rule2.Passed then
    24 DBMS_OUTPUT.put_line( 'Rule 2. PASSED' );
    25 else
    26 DBMS_OUTPUT.put_line( 'Rule 2. FAILED' );
    27 end if;
    28
    29 end;
    30 /
    Rule 1. PASSED
    Rule 2. PASSED
    PL/SQL procedure successfully completed.
    SQL>
    PL/SQL rules can in a similar fashion be subclassed from the base/asbtract class. And rules can be persisted in a table too.
    But even though I did this example to illustrate just how flexible Oracle can be, I would personally think hard before using the above approach myself.
    Why?
    Because rules 1 and 2 resulted in two SQLs being fired. A single SQL could have done the job.
    2 SQLs were used for a single employee. I can use a single SQL to find ALL employees that matches the rule criteria.
    So... not very scalable and not very fast.

Maybe you are looking for