Casting resultSet

Hi All,
Could anyone tell me if it is possible to cast a resultSet to a different type of collection such as a java.util.Collection, java.util.Map or an ArrayList etc?

No. A resultset is not usualy a collection in memory, it is more of a live conection to the database (depending on the driver) this makes it possible to do "select * from alargetable".
You have to read the results into a collection yourself.
Alternatively you can use a rowset object which loads the contents of a resultset into memory. But u still cant cast it into a collection. http://java.sun.com/products/jdbc/download.html#spec
Hope this helps!

Similar Messages

  • Cast ResultSet to Sybase SybResultSet Error

    Hi:
    I'm using weblogic 7.0 and In Connection Pools: I set the driver is com.sybase.jdbc2.jdbc.SybDriver.
    The pool is working.
    I try to upload the image file and save it to the sybase database. I took the
    sample TextPointers.java from weblogic/.../sample2/. Whenever I try to following
    line I get exception.
    from weblogic.jdbc.rmi.SerialResultSet
    SybResultSet rs = (SybResultSet) stmt.executeQuery(getText);
    What is the different between the two drivers:
    com.sybase.jdbc2.jdbc.SybDriver and
    com.sybase.jdbc.SybDriver
    Thanks,
    Hellen.

    Joseph Weinstein <[email protected]_this> wrote:
    >
    >
    Hellen wrote:
    Yes, I need use non standard - jdbc call. after get the ResultSet nextI need to
    do is:
    TextPointer tp = rs.getSybTextPointer(1);
    tp.sendData(file, false); // send the image file to sybase server.
    The actully code is runing on the weblogic server side.Ok. What version of the server are you running? If you must use a non-standard
    JDBC method to do your work, you may have to obtain a link to the underlying
    vendor's connection to make the statement and run the query. This ability
    to
    access the vandor connection is available in the latest SPs of the more
    recent
    server versions.
    JoeThe server is 7.0 with SP2. Could you give me an example how to obtain a link
    to the underlying vendor's connection if I take the connection from connection
    pool which setup on the server side.
    >
    >>
    >>
    Thanks,
    Hellen
    Joseph Weinstein <[email protected]_this> wrote:
    Hellen wrote:
    Hi:
    I'm using weblogic 7.0 and In Connection Pools: I set the driver
    is
    com.sybase.jdbc2.jdbc.SybDriver.
    The pool is working.
    I try to upload the image file and save it to the sybase database.I took the
    sample TextPointers.java from weblogic/.../sample2/. Whenever I
    try
    to following
    line I get exception.
    from weblogic.jdbc.rmi.SerialResultSet
    SybResultSet rs = (SybResultSet) stmt.executeQuery(getText);Hi.Unless you need to make some sybase-specific extra method, thereis
    no]reason for you to try to
    cast the java.sql.ResultSet you are getting. ie: Just do:
    ResultSet rs = stmt.executeQuery(getText);
    If there is a non-standard JDBC call required, we will have to dosomething
    else.
    Where is this code running? In the server or in an external client?
    What is the different between the two drivers:
    com.sybase.jdbc2.jdbc.SybDriver and
    com.sybase.jdbc.SybDriverDunno.... There should be no reason for you to care... I just examined
    their public
    face, and there were no important differences:
    public static final int DEFAULT_DRIVER_VERSION = 5;
    Thanks,
    Hellen.The sybase driver mutates quicker than our releases, so I highly recommend
    you download
    sybase's latest EBF version of their driver and install/use it asopposed
    to the older one we
    packaged (which was the latest when the package was defined)...
    Joe

  • How to configure datasources in tomcat 4.1.12 to obtain OracleResultSets

    Hi!
    Since my application running under both OracleAS and Tomcat 4.1.12 should obtain connection pooling i tried to configure the application servers. Our application makes use of OracleResultSet. I configured OracleAS by editing the data-sources.xml file which works very well:
    <data-source
    class="com.evermind.sql.DriverManagerDataSource"
    name="OracleDS"
    location="jdbc/OracleCoreDS"
    xa-location="jdbc/xa/OracleXADS"
    ejb-location="jdbc/OracleDS"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username="scott"
    password="tiger"
    url="jdbc:oracle:thin:@testdb:1525:ORA5"
    inactivity-timeout="30"
    />
    The code for jndi lookup is here. It works fine when i cast ResultSet to OracleResultSet using OracleAS:
    initCtx = new InitialContext();
    envCtx = (Context) initCtx.lookup("java:comp/env");
    dataSource = (DataSource) envCtx.lookup("jdbc/OracleDS");
    con = dataSource.getConnection();
    ResultSet rs = con.executeQuery("..");
    OracleResultSet orars = (OracleResultSet)rs;
    Then i configured tomcat 4.1.12 server.xml file:
    <Resource name="jdbc/OracleDS" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/OracleDS">
    <parameter><name>username</name><value>scott</value></parameter>
    <parameter><name>password</name><value>tiger</value></parameter>
    <parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
    <parameter><name>url</name><value>jdbc:oracle:thin:@testdb:1525:ORA5</value></parameter>
    </ResourceParams>
    The same source for jndi lookup brings up a ClassCastException at line
    OracleResultSet orars = (OracleResultSet)rs;
    Therefore i tried to add a new parameter in tomcats server.xml:
    <parameter><name>factory</name><value>com.evermind.sql.DriverManagerDataSource</value></parameter>
    Now following exceptions occurs:
    javax.naming.NamingException: Could not create resource factory instance, com.evermind.sql.DriverManagerDataSource
    java.lang.Object org.apache.naming.factory.ResourceFactory.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
    I have oc4j.jar and classes12.jar in tomcats home directory under config/lib.
    How should i configure tomcat to be able to use connection pooling and OracleResultSets?
    Thanks in advance!
    thomas

    ?

  • Casting a JDBC resultSet to VO RowSet?

    Is it possible to somehow transform a plain vanilla jdbc ResultSet to a VO RowSet? (Of course without iterating!) Either by passing the entire object (with all rows intact) or by casting?
    Thanks
    -Nat
    PS. Rob, you know why I want to do this, right&lt;g&gt;?

    We use JDBC to access the database internally. BC4J automates a best-practice use of JDBC PreparedStatements and ResultSet's for you without your having to worry about remembering the low-level details.
    Our generic JDBC-interaction code worries about consistently applying the best-practice and highest-performance JDBC techniques for you. When we discover a further improvement and implement it, all of your view objects immediately benefit in the next release.
    We had a team in Oracle Applications who claimed they could read large amounts of data faster with hand-coded JDBC than with BC4J. They weren't using BC4J in the optimal way and I illustrated by modifying their benchmark how to make BC4J be faster than hand-coded raw use of JDBC.
    Their benchmark wasn't really comparing apples to apples, so I made sure they were comparing roughly equivalent amounts of work before we could conclude what was better.

  • Type cast weblogic.jdbc.wrapper.ResultSet to OracleResultSet

    Hello, I have a application using Spring 3.5 , Hibernate 3.6 and deployed over weblogic 10.3.4.
    This application running fine when i was using the c3po connection pooling, but when i switch to use the weblogic connection pooling, I started getting issues while retriving the XMLTYPE object from database.
    This issue what i am facing is when i am trying to type cast the weblogic wrapper resultset to Oracleresultset i am getting a type casting issue.
    Below is the code...
    Can anyone please help me to find out how to type cast the weblogic wrapper objects. I am stuck on this issue for more thn a week now.. Please help me..
    public Object nullSafeGet( ResultSet rs, String [ ] names, Object arg2 )
    throws HibernateException, SQLException
         System.out.println("rs ========= "+rs.getClass());
    System.out.println("rs ========= "+rs.getClass().getName());
    weblogic.jdbc.wrapper.ResultSet wlsResultSet = (weblogic.jdbc.wrapper.ResultSet) rs;
    System.out.println("wlsResultSet ========= "+wlsResultSet.getClass().getName());
    OracleResultSet oracleResultSet = (OracleResultSet) wlsResultSet.getVendorObj();
    System.out.println("ors ========= "+oracleResultSet.getClass().getName());
    XMLType xmlType = XMLType.createXML(oracleResultSet.getOPAQUE(names[0]));
         //XMLType xmlType = (XMLType)rs.getObject(names[0]);
    return (xmlType != null)?xmlType.getDOM():null;
    }

    Wrong forum, try WebLogic Server - General
    Frank

  • ResultSet.getObject casts to incomplete Date

    Hi,
    I'm using the jdbc driver in java to copy data from an oracle database to a DB2 database.
    The solution is a generic one to copy all columns regardless of type (using PreparedStatement.setObject).
    Everything works as a charm except that the DATE columns will just contain a date and no time.
    After some digging it seems that the ResultSet.getObject method doesn't include the time...I did:
    Object value = inRs.getObject(COLUMN_NAME);
    Date myDate = (Date) value;
    DateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String myDateAsString = format.format(myDate);
    This will give me just the date without the time, is this the expected behaviour?
    getDate and getTimestamp works just fine but I need to use getObject to keep my method generic.
    Any ideas?
    Thanks
    Database: Oracle Database 11g Release 11.1.0.0.0
    JDBC Driver: Oracle Thin 10.2.0.4.0
    JVM: IBM J2RE 1.5.0

    Ok, so I've got a workaround and found the problem.
    Object value = inRs.getObject(column.getKey());
    if (value != null && value.getClass().getName().equals("java.sql.Date"))
    outStatement.setTimestamp(colIndex, inRs.getTimestamp(column.getKey()));
    *} else {*
    outStatement.setObject(colIndex, value);
    getObject erroneously returns a java.sql.Date from the oracle DATE. Is this an error in the jdbc driver?
    UPDATE: According to the manual, this is the default behavior of the driver, but it just doesn't seem rational.
    See Table 11-2 getObject and getOracleObject Return Types:
    http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/datacc.htm
    Edited by: gs1 on May 14, 2009 12:57 AM
    Fixed code.

  • How to get resultset from procedure having dynamic select sql query ?

    Hi,
    I have created a procedure, in which there is dynamic select query. The procedure has one out put parameter which gives error code. When I compile that procedure it compiles successufully. When I run it it executes successfully and gives output error code. But I don't know how to get resultset of that dynamic select sql query. I need that.
    This is the procedure:
    create or replace
    PROCEDURE uspGetProductDetailsMultiOrder
      v_DefinitionDBName IN VARCHAR2,
         v_CommonDBName IN VARCHAR2,
         v_Filter_FilledStatus IN VARCHAR2,
         v_Filter_Internal_Counterparty IN nvarchar2,
         v_Filter_NoteType IN nvarchar2,
         v_Filter_Exchange IN nvarchar2,
         v_Filter_Issuer IN nvarchar2,
         v_Filter_Product_Category  IN VARCHAR2,
         v_DateToFilter IN VARCHAR2,     
         v_Filter_FromDate IN VARCHAR2,
         v_Filter_ToDate IN VARCHAR2,
         v_Active_YN_Flag IN NVARCHAR2,
         v_Entity_ID IN NVARCHAR2,
         v_ErrorNumber  OUT NUMBER
       as
       v_SelectSQL  nvarchar2(32767);
          v_Setting_Name  nvarchar2(32767);
       v_Default_Value  nvarchar2(32767);
       v_Config_Value  nvarchar2(32767);
       v_CCY_ID  NUMBER(10,0);
       v_CCY_Data  nvarchar2(32767);
       v_CCY_List  nvarchar2(32767);
       v_Seq_Id  NUMBER(10,0);
       SWV_Active_YN_Flag NVARCHAR2(1);
       SWV_VarStr long;--varchar2(4000);
       SWV_TRANCOUNT NUMBER(10,0);
        SWV_fnc_SplitString_Id_var1 NUMBER(10,0);
       SWV_fnc_SplitString_Id_var0 NUMBER(10,0);
      CURSOR RestrictTermsheetVisibilityByC 
       IS select CS.Setting_Name,Default_Value,Config_Value
       from Config_Settings CS   LEFT OUTER JOIN Entity_Config EC  ON EC.Setting_ID = CS.Setting_ID
       where EC.Entity_ID = v_Entity_ID AND Setting_Level = 'ENTITY';
       CURSOR Get_RestrictCCY_List_Cursor IS SELECT Id_1,Data_1 FROM table(fnc_SplitString(v_Config_Value,','));
       --CURSOR Get_RestrictCCY_List_Cursor IS SELECT Id,Data FROM imp;
       CURSOR GetRestrictTemplateListCursor 
      -- is select id,data from imp;
       IS SELECT Id_1,Data_1 FROM table(fnc_SplitString(v_Config_Value,',')) ;
         --Parikshit 18-Jul-2010, active YN flag param added in SP
    BEGIN
    SWV_Active_YN_Flag := v_Active_YN_Flag;
       if SWV_Active_YN_Flag = ' '  then
          SWV_Active_YN_Flag := 'Y';
       end if;
       v_SelectSQL := ' ';
       v_SelectSQL := v_SelectSQL || ' Select ';
       v_SelectSQL := v_SelectSQL || '  NM.Note_Master_Id, NM.Product_Name, NM.Template_ID, NM.Template_Sr_No, NM.Asset, NM.Exchange, NM.Type, NM.Currency';
         --SET @SelectSQL = @SelectSQL + ' , NM.Trade_Date, NM.Value_Date, NM.Valuation_Date, NM.Maturity_Date, NM.Tenor, NM.Strike_Price_Percentage, (case when (NM.Type like '' ELN%'' or NM.Type like ''RELN%'') THEN  NOP.Issue_Price Else NM.Customer_Price End) as Customer_Price, NM.Dealer_Price, (case when (NM.Type like '' ELN%'' or NM.Type like ''RELN%'') THEN  NOP.Customer_Yield Else NM.Customer_Yield End) as Customer_Yield,  NOP.Dealer_Cost_PA as Internal_Cost '
       v_SelectSQL := v_SelectSQL || ' , NM.Trade_Date, NM.Value_Date, NM.Valuation_Date, NM.Maturity_Date, NM.Tenor, NM.Strike_Price_Percentage, (case when (NM.PriceList_YN = ''Y'') THEN  NOP.Issue_Price Else NM.Customer_Price End) as Customer_Price, NM.Dealer_Price, (case when (NM.PriceList_YN = ''Y'') THEN  NOP.Customer_Yield Else NM.Customer_Yield End) as Customer_Yield,  NOP.Dealer_Cost_PA as Internal_Cost ';
       v_SelectSQL := v_SelectSQL || ' , NM.Minimum_Issue_Size, NM.Maximum_Issue_Size, NM.Minimum_Tolerence_Amount, NM.Maximum_Tolerence_Amount, NM.Trigger_Amount_Warning, nvl(NM.PerUnit_Equivalent_Amount,1) as PerUnit_Equivalent_Amount,  NM.Active_YN_Flag, NM.Verify_YN_Flag ';
       v_SelectSQL := v_SelectSQL || ' , NM.Tranche_YN_Flag, NM.Launch_Date, NM.Open_Date, NM.Close_Date, NM.PreHedged_YN, NM.Created_By, NM.Created_At,  NM.Verified_At, NM.Verified_By, NM.ISIN, NM.Issuer';
       v_SelectSQL := v_SelectSQL || ' , NM.Product_Catagory as Product_Category, NM.Note_Issuer_Type as Issuer_Category, NM.Series_No as Series_No, NM.Minimum_Investment_Amount ';
         --Added by Parikshit on 14-Jun-2011, to remove the unwinding amounts from the total issue size
         --SET @SelectSQL = @SelectSQL + ' , NOP.LastTimeWhenProductModified,NOP.Nominal_Amount as Current_Issue_Size, NOP.Filled_Status, NM.Counterparty as Internal_Counterparty  '
       v_SelectSQL := v_SelectSQL || ' , NOP.LastTimeWhenProductModified,(NOP.Nominal_Amount - nvl(ND.Unwind_Amount,0) ) as Current_Issue_Size, NOP.Filled_Status, NM.Counterparty as Internal_Counterparty  ';
         --********************************************************END
       v_SelectSQL := v_SelectSQL || ' ,T2.Confirmed_Amount, T2.Confirmed_Shares';
       v_SelectSQL := v_SelectSQL || ' , T3.Live_Deals';
       v_SelectSQL := v_SelectSQL || ' , BS.Net_Trade_Hedged, BS.Net_Trade_Outstanding, BS.Hedged_Nominal_BUY, BS.Hedged_Nominal_SELL, BS.Outstanding_Nominal_BUY, BS.Outstanding_Nominal_SELL   ';
       v_SelectSQL := v_SelectSQL || ' , ( case    When UPPER(NM.PreHedged_YN) = ''Y'' Then ''Launched'' ';
       v_SelectSQL := v_SelectSQL || '              When ((NM.Maturity_Date IS  NOT NULL) AND to_date(NM.Maturity_Date) <= to_date(sysdate)) Then ''Matured''';
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date IS NOT NULL)  Then ''Launched''';     
         --Ready to launch
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date  IS  NULL AND (T2.Confirmed_Amount >= NM.Minimum_Issue_Size) AND  to_date(Close_Date) > to_date(sysdate) ) Then ''Ready To Launch''';     
         --Ready to launch
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date  IS  NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND  to_date(Close_Date)= to_date(sysdate)    )  Then ''Ready To Launch''';     
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date  IS  NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND  to_date(Close_Date)< to_date(sysdate)    )  Then ''Ready To Launch''';     
         --Warning trigger reached
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date IS  NOT NULL AND (T2.Confirmed_Amount >= NM.Trigger_Amount_Warning ))  Then ''Warning Trigger Reached''';          
       v_SelectSQL := v_SelectSQL || '              Else ''Not Ready'' ';
       v_SelectSQL := v_SelectSQL || '              End)Launch_Status';
       v_SelectSQL := v_SelectSQL || ' , NI.Issuer_Code';
          v_SelectSQL := v_SelectSQL || ' , (nvl(NOP.Nominal_Amount,0) - nvl(T2.Confirmed_Amount,0)) as Unconfirmed_Amount, NM.Upfront as Upfront,   case when UPPER(NM.PreHedged_YN) = ''Y'' THEN 0 else (nvl(T2.Confirmed_Amount,0) - nvl(BS.Net_Trade_Hedged,0)) end as ReadyToHedge';
          v_SelectSQL := v_SelectSQL || ' , NOP.Hard_Margin  as Margin_Amount, NM.YearBasis as YearBasis, NM.Note_Product_Rating as Equity_Risk_Score, AD.Equity_Asset_Class ';
          v_SelectSQL := v_SelectSQL || '  , NM.Note_Product_Rating as Product_Rating,  NOP.PO_ID, AD.LotSize as Lot_Size, NM.Max_Orders_Per_Product as MAX_Orders, NOP.Order_Count as Current_Order_Count,  nvl(NM.Denomination_Ccy,NM.Currency) as Denomination_Ccy, NM.Note_Scheme_Type as Underlying_Type, NM.Note_Asset_Class as Asset_Class, NULL as Product_Created_YN, NULL as Product_Created_ID,  ( (case when NM.Note_Order_Type = '''' then N''Market'' else NM.Note_Order_Type end )  ) as  Order_Type, NOP.Spot_Price, NM.Note_Price_Link, NOP.Strike_Price, NVL(NM.C_Fixing_Frequency,''Atmaturity'') as Fixing_Frequency, NM.Document_Uploaded_YN, NM.Document_Uploaded_At, NM.Document_Uploaded_By, NM.Document_File_Name, NM.Document_File_Extension, NM.Document_File_Path, NM.CutOff_Time, NM.Soft_Tenor, NM.NM_Sn_Code_All, NULL as Note_Price_Source, AD.LongName, NVL(NM.Pricelist_YN,''N'') as Pricelist_YN, AD.AlternateIdentifierAlias as Underlying, NM.Note_Issuer_Date_Offset, NM.Counterparty as Note_Counter_Party, NULL as
    Note_Premium_PC  ';
       v_SelectSQL := v_SelectSQL || '  , NI.Issuer_Name, IP.Issuer_Id, IP.Broad_Cash, IP.Odd_Cash, IP.Account_Note, IP.Rounding, IP.Decimal_Truncate, IP.Misc1 as Recidual_YN, NM.Note_Issuer_Type, NM.Target_Coupon, C_Fixing_Frequency as C_Fixing_Frequency, NM.Callable_Frequency as Callable_Frequency, NM.Strike_Price_Percentage as C_Note_Strike_PC, NM.NM_Airbag_PC as  Airbag_PC, C_Note_Barrier_PC as C_Note_Barrier_PC, TM.Template_Name, ''Product'' as Record_Type, NM.C_Settlement_Frequency, NM.Coupon_Frequency, NM.NM_Fixing_Source as Note_Fixing_Source, NM.Order_Entry_Type, (nvl(NM.Minimum_Issue_Size,0) - nvl(T2.Confirmed_Amount,0)) as Remaining_Launch_Amount, NM.C_Fixing_Start_Point, NM.C_Fixing_End_Point, NM.Order_Entry_Type, SC.Scheme_Alias, SC.Scheme_Name, CM.CM_ID, CM.CM_Name as Counterparty_Name, NM.NM_Other_Features as Other_Features, NM.Strike_Price_Percentage as Accrual_Strike, NM.NM_KnockIn as KnockIn, NM.NM_Airbag_Type, NM.NM_Put_strike as Put_Strike, NM.NM_Accrual_Strike,
    NM.NM_Counterparty_Upfront,  NM.Price_Updated_YN as Prices_Updated_YN, AD.Code as Asset_Name,NULL as KO_FREQ_TYPE, NM.Daily_Accumalation_Equities, NM.MaxNoAcc_days, NM.Guaranteed_Days, NM.Leverage_ratio, NM.NORM_IF, NM.NORM_PAIR, NM.NORM_FXRate ';
       v_SelectSQL := v_SelectSQL || ' from ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName|| '.Note_Master NM  ';
       v_SelectSQL := v_SelectSQL || 'Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Issuer_Master NI ';
          v_SelectSQL := v_SelectSQL || ' On NM.Issuer = (case when  ISNUMERIC(NM.Issuer) = 0  then  cast (NI.Issuer_Name as nvarchar2(25))  else  cast(NI.Issuer_Id as nvarchar2(25)) end )';     
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Note_Order_Product NOP ';
       v_SelectSQL := v_SelectSQL || ' On NOP.Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_DefinitionDBName||'.AssetDef AD ';
       v_SelectSQL := v_SelectSQL || ' On AD.Code = NM.Asset';
         v_SelectSQL := v_SelectSQL || ' AND AD.TypeAsset  = substr(NM.Note_Asset_Class,1,2) ';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Issuer_Parameter IP ';
          v_SelectSQL := v_SelectSQL || ' On NM.Issuer = (case when  ISNUMERIC(NM.Issuer) = 0  then  cast (IP.Issuer_Name as nvarchar2(25))  else  cast(IP.Issuer_Id as nvarchar2(25)) end )';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Template_Master TM ';
       v_SelectSQL := v_SelectSQL || ' On  TM.Template_Id =  NM.Template_ID ';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Scheme_Codes SC ';
       v_SelectSQL := v_SelectSQL || ' On  SC.Scheme_Alias =  NM.Type';     
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Counterparty_Master CM ';
       v_SelectSQL := v_SelectSQL || ' On  CM.CM_ID =  NM.Counterparty';     
          v_SelectSQL := v_SelectSQL || ' Left Outer Join      ';
       v_SelectSQL := v_SelectSQL || ' ( ';
       v_SelectSQL := v_SelectSQL || ' Select Note_master_ID, sum(Nominal_Amt) as Unwind_Amount from ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Note_Deals ';
       v_SelectSQL := v_SelectSQL || ' where Prematurity_Date IS NOT NULL';
       v_SelectSQL := v_SelectSQL || ' AND (UPPER(Deletion_Reason ) = ''PART REDEMPTION'' or UPPER(Deletion_Reason ) = ''FULL REDEMPTION'')';
       v_SelectSQL := v_SelectSQL || ' Group by Note_master_ID ';
       v_SelectSQL := v_SelectSQL || ' ) ND ';
       v_SelectSQL := v_SelectSQL || ' On  ND.Note_Master_ID =  NM.Note_Master_ID';
    if  (v_Filter_FilledStatus = ' ' OR UPPER(v_Filter_FilledStatus) = 'ALL' ) then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NOP.Filled_Status IN (' || v_Filter_FilledStatus  || ')';
       end if;                         
         --AND NOP.Internal_Counterparty = 'DEFAULT''
       if(SUBSTR(to_char(v_Filter_Internal_Counterparty),1,4000)= ' ')  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NOP.Internal_Counterparty IN (' || v_Filter_Internal_Counterparty || ')';
       end if;                    
         --SET @SelectSQL = @SelectSQL + ' --Filter--'
       v_SelectSQL := v_SelectSQL || ' LEFT OUTER JOIN ';
       v_SelectSQL := v_SelectSQL || ' (';
       v_SelectSQL := v_SelectSQL || '   select Note_Master_ID, sum(Nominal_Amount) As Confirmed_Amount, sum(No_Of_Shares)  As Confirmed_Shares  ';
       v_SelectSQL := v_SelectSQL || '   from '||v_CommonDBName||'.Note_Order_RM  ';
       v_SelectSQL := v_SelectSQL || '   Where substr(UPPER(Order_Status_Flag),1,6) = ''YYYYYY'' AND substr(substr(UPPER(Order_Status_Flag),1,7),-1,1) = ''N'' ';
       v_SelectSQL := v_SelectSQL || '   group by  Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' ) T2';
       v_SelectSQL := v_SelectSQL || ' ON T2.Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' LEFT OUTER JOIN';
       v_SelectSQL := v_SelectSQL || ' (';
       v_SelectSQL := v_SelectSQL || '   Select ND.Note_Master_ID, sum(ND.Nominal_Amt) As Live_Deals ';
       v_SelectSQL := v_SelectSQL || '   from '||v_CommonDBName||'.Note_Deals ND  ';
       v_SelectSQL := v_SelectSQL || '   where ND.Active_YNFlag = ''Y'' ';
       v_SelectSQL := v_SelectSQL || '   group by  Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' ) T3';
       v_SelectSQL := v_SelectSQL || ' ON T3.Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  LEFT OUTER JOIN';
       v_SelectSQL := v_SelectSQL || '  (';
       v_SelectSQL := v_SelectSQL || '  SELECT NH_Note_Master_ID,';
       v_SelectSQL := v_SelectSQL || '  (CAST(SUM(Hedged_Nominal_Buy) AS BINARY_FLOAT) -CAST(SUM(Hedged_Nominal_Sell) AS BINARY_FLOAT))  Net_Trade_Hedged,';
       v_SelectSQL := v_SelectSQL || '  (CAST(SUM(Outstanding_Nominal_BUY) AS BINARY_FLOAT) -CAST(SUM(Outstanding_Nominal_SELL) AS BINARY_FLOAT))  Net_Trade_Outstanding,';
       v_SelectSQL := v_SelectSQL || '  SUM(Hedged_Nominal_BUY) AS Hedged_Nominal_BUY,';
       v_SelectSQL := v_SelectSQL || '  SUM(Hedged_Nominal_SELL) AS Hedged_Nominal_SELL,';
       v_SelectSQL := v_SelectSQL || '  SUM(Outstanding_Nominal_BUY) AS Outstanding_Nominal_BUY,';
       v_SelectSQL := v_SelectSQL || '  SUM(Outstanding_Nominal_SELL) As Outstanding_Nominal_SELL';
       v_SelectSQL := v_SelectSQL || '  From';
       v_SelectSQL := v_SelectSQL || '  (';
       v_SelectSQL := v_SelectSQL || '  SELECT NH_Note_Master_ID,';
       v_SelectSQL := v_SelectSQL || '  SUM(NH_Hedged_Nominal) AS Hedged_Nominal_BUY, 0 AS Hedged_Nominal_SELL,';
       v_SelectSQL := v_SelectSQL || '  SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_BUY, 0 AS Outstanding_Nominal_SELL';
       v_SelectSQL := v_SelectSQL || '  FROM '||v_CommonDBName||'.Note_Hedge  ';
       v_SelectSQL := v_SelectSQL || '  WHERE NH_Direction = ''BUY'' ';
       v_SelectSQL := v_SelectSQL || '  GROUP BY NH_Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  Union';
       v_SelectSQL := v_SelectSQL || '  SELECT NH_Note_Master_ID,';
       v_SelectSQL := v_SelectSQL || '  0 AS Hedged_Nominal_BUY, SUM(NH_Hedged_Nominal) AS Hedged_Nominal_SELL,';
       v_SelectSQL := v_SelectSQL || '  0 AS Outstanding_Nominal_BUY, SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_SELL';
       v_SelectSQL := v_SelectSQL || '  FROM '||v_CommonDBName||'.Note_Hedge  ';
       v_SelectSQL := v_SelectSQL || '  WHERE NH_Direction = ''SELL''  ';
       v_SelectSQL := v_SelectSQL || '  GROUP BY NH_Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  ) ';
       v_SelectSQL := v_SelectSQL || '  GROUP BY NH_Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  ) BS';
       v_SelectSQL := v_SelectSQL || '  ON BS.NH_Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' Where NM.Verify_YN_Flag = ''Y'' ';
      v_SelectSQL := v_SelectSQL || ' AND NM.Active_YN_Flag = ''' || SWV_Active_YN_Flag || '''';
       if(SUBSTR(to_char(v_Filter_NoteType),1,4000) = ' ' OR UPPER(v_Filter_NoteType) = 'ALL' ) then
               v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NM.Type IN (' || v_Filter_NoteType  || ')';
       end if;     
    IF UPPER(v_Entity_ID) <> 'ALL'  then
          OPEN RestrictTermsheetVisibilityByC;
          FETCH RestrictTermsheetVisibilityByC INTO v_Setting_Name,v_Default_Value,v_Config_Value;
          WHILE RestrictTermsheetVisibilityByC%FOUND   LOOP
         --2) Convert comma separated ccy (CNY,HKD,USD) string to single quote ccy with comma separated Ccy ('CNY','HKD','USD') string
             if (UPPER(v_Setting_Name) = 'RESTRICT_TERMSHEET_VISIBILITY_BY_CCY')  then
                if v_Config_Value is not null  then
              SELECT COUNT(Id_1) INTO SWV_fnc_SplitString_Id_var0 FROM TABLE(fnc_SplitString(v_Config_Value,',')) ;
                   IF (SWV_fnc_SplitString_Id_var0 > 0)  then
                        --print 'Before Single  quote separated ccy : ' + '''' + @Config_Value + ''''
                      v_Seq_Id := 0;
                      OPEN Get_RestrictCCY_List_Cursor;
                      FETCH Get_RestrictCCY_List_Cursor
                      INTO v_CCY_ID,v_CCY_Data;
                      WHILE Get_RestrictCCY_List_Cursor%FOUND   LOOP
                         if v_Seq_Id = 0  then
                            v_CCY_List := '''' || v_CCY_Data || '''';
                         else
                            v_CCY_List := v_CCY_List || ',' || '''' || v_CCY_Data || '''';
                         end if;
                         v_Seq_Id := v_Seq_Id+1;
                         FETCH Get_RestrictCCY_List_Cursor INTO v_CCY_ID,v_CCY_Data;
                      END LOOP;
                      CLOSE Get_RestrictCCY_List_Cursor;
                        --print 'After Single quote ccy : ' + @CCY_List
                      v_SelectSQL := v_SelectSQL || ' AND nvl(NM.Denomination_Ccy,NM.Currency) NOT IN (' || v_CCY_List   || ')';
                   end if;
                end if;
             end if;
    --3) Convert comma separated template (ELN,BELN,BELN_B) string to single quote template code with comma separated template ('ELN','BELN','BELN_B') string
             if (UPPER(v_Setting_Name) = 'RESTRICT_TERMSHEET_VISIBILITY_BY_SUBSCHEME')  then
                if v_Config_Value is not null then
          SELECT COUNT(Id_1) INTO SWV_fnc_SplitString_Id_var1 FROM TABLE(fnc_SplitString(v_Config_Value,',')) ;
                   IF (SWV_fnc_SplitString_Id_var1 > 0)  then
                      v_Seq_Id := 0;
                      OPEN GetRestrictTemplateListCursor;
                      FETCH GetRestrictTemplateListCursor
                      INTO v_CCY_ID,v_CCY_Data;
                      WHILE GetRestrictTemplateListCursor%FOUND 
                      LOOP
                         if v_Seq_Id = 0  then
                            v_CCY_List := '''' || v_CCY_Data || '''';
                         else
                            v_CCY_List := v_CCY_List || ',' || '''' || v_CCY_Data || '''';
                         end if;
                         v_Seq_Id := v_Seq_Id+1;
                         FETCH GetRestrictTemplateListCursor INTO v_CCY_ID,v_CCY_Data;
                      END LOOP;
                      CLOSE GetRestrictTemplateListCursor;
                   --print 'After Single quote template code: ' + @CCY_List
                      v_SelectSQL := v_SelectSQL || ' AND TM.Template_Code NOT IN (' || v_CCY_List   || ')';
                   end if;
                end if;
             end if;
             FETCH RestrictTermsheetVisibilityByC INTO v_Setting_Name,v_Default_Value,v_Config_Value;
          END LOOP;
          CLOSE RestrictTermsheetVisibilityByC;
       end if;
      if  (v_Filter_Exchange = ' ' OR UPPER(v_Filter_Exchange) = 'ALL')  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NM.Exchange IN (' || v_Filter_Exchange  || ')';
       end if;                         
         --SET @SelectSQL = @SelectSQL + ' --AND NM.Issuer = 4'
      if  (v_Filter_Issuer = ' ' OR UPPER(v_Filter_Issuer) = 'ALL') then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NM.Issuer IN (' || v_Filter_Issuer  || ')';
       end if;     
          if  v_Filter_Product_Category    = ' '  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND UPPER(NM.Note_Issuer_Type) IN (''' || v_Filter_Product_Category  || ''')';
       end if;          
       if UPPER(v_DateToFilter) = 'NA'  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          if UPPER(v_DateToFilter) = 'CLOSE_DATE'  then
             v_SelectSQL := v_SelectSQL || ' AND to_char( '|| v_DateToFilter || ') >= to_date(''' || v_Filter_ToDate ||  ''');
                             -- AND convert(smalldatetime,''' || v_Filter_ToDate || ''',106) ';
          else
             v_SelectSQL := v_SelectSQL || ' AND to_char(''' || v_DateToFilter || ''') BETWEEN to_date(''' || v_Filter_FromDate ||  ''') AND to_date(''' || v_Filter_ToDate || ''') ';
          end if;
       end if;
       v_SelectSQL := v_SelectSQL || ' Order by NM.Product_Name';
       SWV_VarStr := v_SelectSQL;
       DBMS_OUTPUT.PUT_LINE(SWV_VarStr);
       EXECUTE IMMEDIATE SWV_VarStr;
       IF SQLCODE <> 0  then
          GOTO ERROR_HANDLER;
       end if;
       IF SQL%rowcount > 0  then
          COMMIT;
          SWV_TRANCOUNT := SWV_TRANCOUNT -1;
       end if;     --Commit Transaction
       v_ErrorNumber := SQLCODE;
       RETURN;
       << ERROR_HANDLER >> v_ErrorNumber := SQLCODE;
       ROLLBACK;
       SWV_TRANCOUNT := 0;     --Rollback Transaction
       RETURN;
    END;Please suggest something. Thanks
    Edited by: BluShadow on 30-Nov-2011 11:00
    added {noformat}{noformat} tags for formatting of code.  Please read {message:id=9360002} to learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Connecting to the database sample_adf_finiq_common.
    Select NM.Note_Master_Id, NM.Product_Name, NM.Template_ID, NM.Template_Sr_No, NM.Asset, NM.Exchange, NM.Type, NM.Currency , NM.Trade_Date, NM.Value_Date, NM.Valuation_Date, NM.Maturity_Date, NM.Tenor, NM.Strike_Price_Percentage, (case when (NM.PriceList_YN = 'Y') THEN NOP.Issue_Price Else NM.Customer_Price End) as Customer_Price, NM.Dealer_Price, (case when (NM.PriceList_YN = 'Y') THEN NOP.Customer_Yield Else NM.Customer_Yield End) as Customer_Yield, NOP.Dealer_Cost_PA as Internal_Cost , NM.Minimum_Issue_Size, NM.Maximum_Issue_Size, NM.Minimum_Tolerence_Amount, NM.Maximum_Tolerence_Amount, NM.Trigger_Amount_Warning, nvl(NM.PerUnit_Equivalent_Amount,1) as PerUnit_Equivalent_Amount, NM.Active_YN_Flag, NM.Verify_YN_Flag , NM.Tranche_YN_Flag, NM.Launch_Date, NM.Open_Date, NM.Close_Date, NM.PreHedged_YN, NM.Created_By, NM.Created_At, NM.Verified_At, NM.Verified_By, NM.ISIN, NM.Issuer , NM.Product_Catagory as Product_Category, NM.Note_Issuer_Type as Issuer_Category, NM.Series_No as Series_No, NM.Minimum_Investment_Amount , NOP.LastTimeWhenProductModified,(NOP.Nominal_Amount - nvl(ND.Unwind_Amount,0) ) as Current_Issue_Size, NOP.Filled_Status, NM.Counterparty as Internal_Counterparty ,T2.Confirmed_Amount, T2.Confirmed_Shares , T3.Live_Deals , BS.Net_Trade_Hedged, BS.Net_Trade_Outstanding, BS.Hedged_Nominal_BUY, BS.Hedged_Nominal_SELL, BS.Outstanding_Nominal_BUY, BS.Outstanding_Nominal_SELL , ( case When UPPER(NM.PreHedged_YN) = 'Y' Then 'Launched' When ((NM.Maturity_Date IS NOT NULL) AND to_date(NM.Maturity_Date) <= to_date(sysdate)) Then 'Matured' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NOT NULL) Then 'Launched' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NULL AND (T2.Confirmed_Amount >= NM.Minimum_Issue_Size) AND to_date(Close_Date) > to_date(sysdate) ) Then 'Ready To Launch' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND to_date(Close_Date)= to_date(sysdate) ) Then 'Ready To Launch' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND to_date(Close_Date)< to_date(sysdate) ) Then 'Ready To Launch' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NOT NULL AND (T2.Confirmed_Amount >= NM.Trigger_Amount_Warning )) Then 'Warning Trigger Reached' Else 'Not Ready' End)Launch_Status , NI.Issuer_Code , (nvl(NOP.Nominal_Amount,0) - nvl(T2.Confirmed_Amount,0)) as Unconfirmed_Amount, NM.Upfront as Upfront, case when UPPER(NM.PreHedged_YN) = 'Y' THEN 0 else (nvl(T2.Confirmed_Amount,0) - nvl(BS.Net_Trade_Hedged,0)) end as ReadyToHedge , NOP.Hard_Margin as Margin_Amount, NM.YearBasis as YearBasis, NM.Note_Product_Rating as Equity_Risk_Score, AD.Equity_Asset_Class , NM.Note_Product_Rating as Product_Rating, NOP.PO_ID, AD.LotSize as Lot_Size, NM.Max_Orders_Per_Product as MAX_Orders, NOP.Order_Count as Current_Order_Count, nvl(NM.Denomination_Ccy,NM.Currency) as Denomination_Ccy, NM.Note_Scheme_Type as Underlying_Type, NM.Note_Asset_Class as Asset_Class, NULL as Product_Created_YN, NULL as Product_Created_ID, ( (case when NM.Note_Order_Type = '' then N'Market' else NM.Note_Order_Type end ) ) as Order_Type, NOP.Spot_Price, NM.Note_Price_Link, NOP.Strike_Price, NVL(NM.C_Fixing_Frequency,'Atmaturity') as Fixing_Frequency, NM.Document_Uploaded_YN, NM.Document_Uploaded_At, NM.Document_Uploaded_By, NM.Document_File_Name, NM.Document_File_Extension, NM.Document_File_Path, NM.CutOff_Time, NM.Soft_Tenor, NM.NM_Sn_Code_All, NULL as Note_Price_Source, AD.LongName, NVL(NM.Pricelist_YN,'N') as Pricelist_YN, AD.AlternateIdentifierAlias as Underlying, NM.Note_Issuer_Date_Offset, NM.Counterparty as Note_Counter_Party, NULL as
    Note_Premium_PC , NI.Issuer_Name, IP.Issuer_Id, IP.Broad_Cash, IP.Odd_Cash, IP.Account_Note, IP.Rounding, IP.Decimal_Truncate, IP.Misc1 as Recidual_YN, NM.Note_Issuer_Type, NM.Target_Coupon, C_Fixing_Frequency as C_Fixing_Frequency, NM.Callable_Frequency as Callable_Frequency, NM.Strike_Price_Percentage as C_Note_Strike_PC, NM.NM_Airbag_PC as Airbag_PC, C_Note_Barrier_PC as C_Note_Barrier_PC, TM.Template_Name, 'Product' as Record_Type, NM.C_Settlement_Frequency, NM.Coupon_Frequency, NM.NM_Fixing_Source as Note_Fixing_Source, NM.Order_Entry_Type, (nvl(NM.Minimum_Issue_Size,0) - nvl(T2.Confirmed_Amount,0)) as Remaining_Launch_Amount, NM.C_Fixing_Start_Point, NM.C_Fixing_End_Point, NM.Order_Entry_Type, SC.Scheme_Alias, SC.Scheme_Name, CM.CM_ID, CM.CM_Name as Counterparty_Name, NM.NM_Other_Features as Other_Features, NM.Strike_Price_Percentage as Accrual_Strike, NM.NM_KnockIn as KnockIn, NM.NM_Airbag_Type, NM.NM_Put_strike as Put_Strike, NM.NM_Accrual_Strike,
    NM.NM_Counterparty_Upfront, NM.Price_Updated_YN as Prices_Updated_YN, AD.Code as Asset_Name,NULL as KO_FREQ_TYPE, NM.Daily_Accumalation_Equities, NM.MaxNoAcc_days, NM.Guaranteed_Days, NM.Leverage_ratio, NM.NORM_IF, NM.NORM_PAIR, NM.NORM_FXRate from Sample_ADF_finiq_Common.Note_Master NM Left Outer Join Sample_ADF_finiq_Common.Issuer_Master NI On NM.Issuer = (case when ISNUMERIC(NM.Issuer) = 0 then cast (NI.Issuer_Name as nvarchar2(25)) else cast(NI.Issuer_Id as nvarchar2(25)) end ) Left Outer Join Sample_ADF_finiq_Common.Note_Order_Product NOP On NOP.Note_Master_ID = NM.Note_Master_ID Left Outer Join Sample_ADF_finiq_Common.AssetDef AD On AD.Code = NM.Asset AND AD.TypeAsset = substr(NM.Note_Asset_Class,1,2) Left Outer Join Sample_ADF_finiq_Common.Issuer_Parameter IP On NM.Issuer = (case when ISNUMERIC(NM.Issuer) = 0 then cast (IP.Issuer_Name as nvarchar2(25)) else cast(IP.Issuer_Id as nvarchar2(25)) end ) Left Outer Join Sample_ADF_finiq_Common.Template_Master TM On TM.Template_Id = NM.Template_ID Left Outer Join Sample_ADF_finiq_Common.Scheme_Codes SC On SC.Scheme_Alias = NM.Type Left Outer Join Sample_ADF_finiq_Common.Counterparty_Master CM On CM.CM_ID = NM.Counterparty Left Outer Join      ( Select Note_master_ID, sum(Nominal_Amt) as Unwind_Amount from Sample_ADF_finiq_Common.Note_Deals where Prematurity_Date IS NOT NULL AND (UPPER(Deletion_Reason ) = 'PART REDEMPTION' or UPPER(Deletion_Reason ) = 'FULL REDEMPTION') Group by Note_master_ID ) ND On ND.Note_Master_ID = NM.Note_Master_ID AND NOP.Internal_Counterparty IN (1) LEFT OUTER JOIN ( select Note_Master_ID, sum(Nominal_Amount) As Confirmed_Amount, sum(No_Of_Shares) As Confirmed_Shares from Sample_ADF_finiq_Common.Note_Order_RM Where substr(UPPER(Order_Status_Flag),1,6) = 'YYYYYY' AND substr(substr(UPPER(Order_Status_Flag),1,7),-1,1) = 'N' group by Note_Master_ID ) T2 ON T2.Note_Master_ID = NM.Note_Master_ID LEFT OUTER JOIN ( Select ND.Note_Master_ID, sum(ND.Nominal_Amt) As Live_Deals from Sample_ADF_finiq_Common.Note_Deals ND where ND.Active_YNFlag = 'Y' group by Note_Master_ID ) T3 ON T3.Note_Master_ID = NM.Note_Master_ID LEFT OUTER JOIN ( SELECT NH_Note_Master_ID, (CAST(SUM(Hedged_Nominal_Buy) AS BINARY_FLOAT) -CAST(SUM(Hedged_Nominal_Sell) AS BINARY_FLOAT)) Net_Trade_Hedged, (CAST(SUM(Outstanding_Nominal_BUY) AS BINARY_FLOAT) -CAST(SUM(Outstanding_Nominal_SELL) AS BINARY_FLOAT)) Net_Trade_Outstanding, SUM(Hedged_Nominal_BUY) AS Hedged_Nominal_BUY, SUM(Hedged_Nominal_SELL) AS Hedged_Nominal_SELL, SUM(Outstanding_Nominal_BUY) AS Outstanding_Nominal_BUY, SUM(Outstanding_Nominal_SELL) As Outstanding_Nominal_SELL From ( SELECT NH_Note_Master_ID, SUM(NH_Hedged_Nominal) AS Hedged_Nominal_BUY, 0 AS Hedged_Nominal_SELL, SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_BUY, 0 AS Outstanding_Nominal_SELL FROM Sample_ADF_finiq_Common.Note_Hedge WHERE NH_Direction = 'BUY' GROUP BY NH_Note_Master_ID Union SELECT NH_Note_Master_ID, 0 AS Hedged_Nominal_BUY, SUM(NH_Hedged_Nominal) AS Hedged_Nominal_SELL, 0 AS Outstanding_Nominal_BUY, SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_SELL FROM Sample_ADF_finiq_Common.Note_Hedge WHERE NH_Direction = 'SELL' GROUP BY NH_Note_Master_ID ) GROUP BY NH_Note_Master_ID ) BS ON BS.NH_Note_Master_ID = NM.Note_Master_ID Where NM.Verify_YN_Flag = 'Y' AND NM.Active_YN_Flag = 'Y' AND UPPER(NM.Note_Issuer_Type) IN ('Internal') AND to_char('16-oct-11') BETWEEN to_date('15-oct-11') AND to_date('17-oct-11') Order by NM.Product_Name
    V_ERRORNUMBER = 0
    Process exited.
    Disconnecting from the database sample_adf_finiq_common.
    here v_errornumber=0 is the output when i run it in oracle sql developer.

  • Explicit cast needed to convert java.* to to oracle.*

    Hello,
    I am trying to compile and run the following JSP but keep getting the "Incompatible type for = Explicit cast needed ..." error. The JSP and oracle procedure code are as follows:
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="oracle.jdbc.driver.*" %>
    <HTML>
    <HEAD>
    <TITLE>
    SimpleQuery JSP
    </TITLE>
    </HEAD>
    <BODY BGCOLOR=EOFFFO>
    <TABLE BORDER=1 BGCOLOR="C0C0C0">
    <TH BGCOLOR="white"> <I>Node ID</I> </TH>
    <%
         Connection con = null;
    OracleCallableStatement cstmt= null;
         ResultSet rs = null;
    try {
              String SYSTEM_DB_DRIVER =
    "oracle.jdbc.driver.OracleDriver";
    String SYSTEM_DB_URL =
    "jdbc:oracle:thin:@myserver.com:1521:";
    String SYSTEM_DB_FILE = "CONN_STRING";
    String SYSTEM_DB_USER = "UNAME";
    String SYSTEM_DB_PASSWORD = "PASSWD";
              Class.forName(SYSTEM_DB_DRIVER);
    con = DriverManager.getConnection(SYSTEM_DB_URL +
    SYSTEM_DB_FILE, SYSTEM_DB_USER, SYSTEM_DB_PASSWORD);
              cstmt = con.prepareCall("call eaicl_p_requirement.open_rule_dtl(?,?)");
              cstmt.registerOutParameter(1, OracleTypes.CURSOR);
    <<I think I have to pass the p_product_id_in here but not sure how>>
              cstmt.execute();
              rs = ((OracleCallableStatement)cstmt).getCursor(1);
              while(rs.next())
              {%>
         <TR>
         <TD ALIGN=CENTER> <%= rs.getString(1) %> </TD>
         <TD ALIGN=CENTER> <%= rs.getInt(2) %> </TD>
    </TR>
              <%}
                   rs.close();
    cstmt.close();
    con.close();
    catch(Exception e)
    %>
    </TABLE>
    </BODY>
    </HTML>
    The Oracle PL/SQL package.procedure it is calling is:
         PROCEDURE open_rules_dtl (
              prc_rules_dtl_out          OUT     rc_fetch_rule_dtl,
              p_product_id_in          IN          NUMBER )
         IS
              vrc_rules_dtl               rc_fetch_rule_dtl;
         BEGIN
              OPEN vrc_rules_dtl FOR
                   SELECT
                        r.rule_id,
                        r.rule_name,
                        r.rule_objective,
                        r.rule_description,
                        r.clearance_requirement,
                        r.rule_type
                   FROM
                        eaicl_rule r
                   WHERE
                        r.is_old = 'N' AND
                        r.product_id = CHR( p_product_id_in )
                   ORDER BY
                        r.rule_name
              prc_rules_dtl_out := vrc_rules_dtl;
    END open_rules_dtl;
    I keep getting the following error on the webserver:
    [05/Dec/2001:16:56:02] info ( 632): JSP: JSP1x compiler threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSPC:\iPlanet\Server4\https-wacc\config\..\ClassCache\_jsps\_ss_test5_jsp.java:84: Incompatible type for =. Explicit cast needed to convert java.sql.CallableStatement to oracle.jdbc.driver.OracleCallableStatement.
              cstmt = con.prepareCall("call eaicl_p_requirement.open_rule_dtl(?,?)");
              ^
    I'm not sure how to fix it. I also need to pass the p_product_id parameter to the procedure.
    Hope someone can point me in the right direction. Thanks.

    Here's how you do an explicit cast:cstmt = (OracleCallableStatement)con.prepareCall("call eaicl_p_requirement.open_rule_dtl(?,?)");

  • How can I catch a resultset thrown out by PL/SQL procedure or function.

    hi,
    I want to write a program in java which receives a resultset
    from PL/SQL , how can I do that.
    I don't want to create the resultset by passing a simple sql
    statement, I want the sql statement to be executed in the
    procedure or function,
    which in turn returns a PL/SQL table of records, or refcursor,
    and capture it in the resultset.

    Here's a quick note on how I do it:
    1. RETURN a REF CURSOR from your PL/SQL function.
    2. In your Java program, you declare the return type from the
    Statement as OracleTypes.CURSOR.
    /* Prepare your PL/SQL function call here */
    CallableStatement mystatement = myconnection.prepareCall
    ( "BEGIN ? := myfunction( p_param => ? ); END;" );
    /* Register the Oracle REF CURSOR as the return type */
    mystatement.registerOutParameter(1, OracleTypes.CURSOR);
    /* Set any additional input parameters to your function */
    mystatement.setString(2, "Param value");
    3. When you fetch the cursor from your Statement, do getObject
    () and then cast the Object as a ResultSet e.g.:
    mystatement.execute);
    ResultSet rs = (ResultSet) mystatement.getObject(1);
    /* Now you can iterate through the ResultSet in the same way as
    for any other JDBC ResultSet */
    while (rset.next())
    /* Fetch the values from your REF CURSOR here */
    mystatement.close();
    There may be better ways to do this, but it works for me.
    Regards,
    Chris I've put in a few more details above. Sorry I can't copy in a
    whole chunk of code for you, but this should be enough to get
    you started. I would recommend the Wrox Press book on
    application programming with Oracle 8i, as it includes lots of
    examples of many different tools for Oracle 8i e.g. JDBC, EJB,
    BC4J, Portal, XML etc.
    Good luck,
    Chris

  • Getting Error:::oracle.jbo.domain.Date cannot be cast to java.lang.String

    Hi Friends,
    I have simple req'.
    i have one date filed in OAF page...if user has change the date filed..means if he incresed by 2 days..then i need to call one procedure..if not no need to call....
    first am picking that date field to by uusing prepared stmt and putting in to one variable..like below
    try {
    ps1 = am.getOADBTransaction().getJdbcConnection().prepareStatement("SELECT -------");
    ResultSet rs2 = ps1.executeQuery();
    while (rs2.next()) {
    schDate = rs2.getString(1);//storing the value
    } catch (Exception e) {
    throw OAException.wrapperException(e);
    Next..am picking the current value like this(user can change the value) like below...
    OAViewObject viewObj = (OAViewObject)am.findViewObject("simpleVO");
    String currSchDate = (String)viewObj.getCurrentRow().getAttribute("iDate");
    java.text.SimpleDateFormat dtFormat = new java.text.SimpleDateFormat ("MM/dd/yyyy");
    StringBuilder date = new StringBuilder(dtFormat.format(currSchDate));
    Then am comparing the values like below..
    if (schDate.equals(date)) {
    String outParamValue = "";
    String secondOutParamValue = "";
    but am geting the below error
    ## Detail 0 ##
    java.lang.ClassCastException: oracle.jbo.domain.Date cannot be cast to java.lang.String
         at xxuss.oracle.apps.abc.webui.xxPGCO15.processFormRequest(xxGCO15.java:594)
    Appriciate any help...its very urgent
    Regards
    Harry

    Instead of :
    String currSchDate = (String)viewObj.getCurrentRow().getAttribute("iDate");Try
    String currSchDate = viewObj.getCurrentRow().getAttribute("iDate").toString();
    -Anand

  • Bad performance with many xmlqueries in select and big resultset

    I'm running into big performance problems with the following query (edited the query a bit to remove sensitive information):
    SELECT id "id",created "created",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/element2/name' passing xml returning content) as varchar2(182))"element2Name",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/element3/name' passing xml returning content) as varchar2(182))"element3Name",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/ror/gcor' passing xml returning content) as varchar2(5))"gcor",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:cStatus' passing xml returning content) as integer)"cStatus",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:lrrm' passing xml returning content) as integer)"lrrm",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:sent' passing xml returning content) as integer)"sent",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:success' passing xml returning content) as integer)"success",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:processStep' passing xml returning content) as integer)"processStep",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/header/status/aseod' passing xml returning content) as number(1))"aseod",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/submission/deferred' passing xml returning content) as number(1))"deferred",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/header/status/eventReportReceived' passing xml returning content) as number(1))"eventReports",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:isOpen' passing xml returning content) as number(1))"isOpen",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:hasNotes' passing xml returning content) as number(1))"hasNotes"
    FROM tablename,xmltable(xmlnamespaces(default 'http://www.example.com/myproject/schema/namespace2','http://www.example.com/myproject/schema/common' as "c"),'/element1' passing xml columns
    created timestamp path 'c:element1Header/c:creationTime/text()',
    organization_id integer path 'c:element1Header/c:organization/c:organizationId/text()',
    is_sender number(1) path 'c:element1Header/c:isSender/text()')
    WHERE organization_id = 5 AND is_sender = 1 AND created >= sysdate-20 AND created <= sysdate+1;This query is fast as long as the results is small (<1000), but when the resultset grows bigger, the performance seems to decrease exponentially. The cause of this slowdown seems to be in the xmlqueries; commenting out the xmlqueries makes the query very fast again (in the order of a few seconds), even with a 15000+ resultset, while including the xmlqueries makes the query take many minutes.
    Workaround I tried: using a rownum < 1000 works fairly well, but only if I don't use order by (which is required). order by forces the resultset to be full built regardless of the rownum limit. (this was done with a subquery orderby and a rownum on the superquery)
    Other workaround i tried: Having the subquery only return the xml column, and doing the xmlqueries in the superquery. I couldn't get this to work, something about no longer having a key-preserved table.
    Background info about the database: Oracle 11.2.0.3.0, binary xmltype column, with a xmlindex unstructured component on all paths in this query, and a structured component with secondary indexes on the paths used in the WHERE (created, organization_id and is_sender). Database has about 140k records total.
    My question is, if anyone knows if this xmlquery bottleneck can be remedied somehow?
    Addition: graph i made indicating the performance at different resultset sizes. Horizontal axis is size of resultset, vertical axis is time spent in seconds: http://i.imgur.com/F2tyg.png

    Just count(*), nothing else in the select:
    COUNT(*)              
    15432                 
    Plan hash value: 1584286506
    | Id  | Operation                      | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                       |     1 |    39 |    31   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE                |                       |     1 |    39 |            |          |
    |*  2 |   FILTER                       |                       |       |       |            |          |
    |   3 |    NESTED LOOPS                |                       |    15 |   585 |    31   (0)| 00:00:01 |
    |   4 |     TABLE ACCESS BY INDEX ROWID| TABLENAME_SC          |    15 |   405 |    16   (0)| 00:00:01 |
    |*  5 |      INDEX RANGE SCAN          | TABLENAME_SC_SUB_IX   |    15 |       |     3   (0)| 00:00:01 |
    |   6 |     TABLE ACCESS BY USER ROWID | TABLENAME             |     1 |    12 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYSDATE@!-500<=SYSDATE@!-50)
       5 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
                  "SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)Original query with ORDER BY on 2 structured component columns, 1 descending and 1 ascending (NOTE: While the explain plan says the time is 00:00:01, the query takes 763 seconds to complete)
    | Id  | Operation                      | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                                |    15 | 23880 |    32   (4)| 00:00:01 |
    |   1 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |   4 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  5 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    16 |   656 |     5   (0)| 00:00:01 |
    |*  6 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    16 |       |     3   (0)| 00:00:01 |
    |   7 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  8 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    15 |   615 |     4   (0)| 00:00:01 |
    |*  9 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    15 |       |     3   (0)| 00:00:01 |
    |  10 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 11 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 12 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  13 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 14 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 15 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  16 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 17 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 18 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  19 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 20 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 21 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  22 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 23 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 24 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  25 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 26 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 27 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  28 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 29 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     8 |   328 |     4   (0)| 00:00:01 |
    |* 30 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     8 |       |     3   (0)| 00:00:01 |
    |  31 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 32 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 33 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  34 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 35 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 36 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  37 |  SORT ORDER BY                 |                                |    15 | 23880 |    32   (4)| 00:00:01 |
    |* 38 |   FILTER                       |                                |       |       |            |          |
    |  39 |    NESTED LOOPS                |                                |    15 | 23880 |    31   (0)| 00:00:01 |
    |  40 |     TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |    15 |  1350 |    16   (0)| 00:00:01 |
    |* 41 |      INDEX RANGE SCAN          | TABLENAME_SC_SUB_IX            |    15 |       |     3   (0)| 00:00:01 |
    |  42 |     TABLE ACCESS BY USER ROWID | TABLENAME                      |     1 |  1502 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_XMLI_LOC_ISNODE("SYS_P1"."LOCATOR")=1)
       3 - access("SYS_P1"."RID"=:B1 AND "SYS_P1"."PATHID"=HEXTORAW('509D') )
       5 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
       6 - access("SYS_P3"."RID"=:B1 AND "SYS_P3"."PATHID"=HEXTORAW('4FDE') )
       8 - filter(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1)
       9 - access("SYS_P5"."RID"=:B1 AND "SYS_P5"."PATHID"=HEXTORAW('7129') )
      11 - filter(SYS_XMLI_LOC_ISNODE("SYS_P7"."LOCATOR")=1)
      12 - access("SYS_P7"."RID"=:B1 AND "SYS_P7"."PATHID"=HEXTORAW('73C0') )
      14 - filter(SYS_XMLI_LOC_ISNODE("SYS_P9"."LOCATOR")=1)
      15 - access("SYS_P9"."RID"=:B1 AND "SYS_P9"."PATHID"=HEXTORAW('3092') )
      17 - filter(SYS_XMLI_LOC_ISNODE("SYS_P11"."LOCATOR")=1)
      18 - access("SYS_P11"."RID"=:B1 AND "SYS_P11"."PATHID"=HEXTORAW('30AA') )
      20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P13"."LOCATOR")=1)
      21 - access("SYS_P13"."RID"=:B1 AND "SYS_P13"."PATHID"=HEXTORAW('3415') )
      23 - filter(SYS_XMLI_LOC_ISNODE("SYS_P15"."LOCATOR")=1)
      24 - access("SYS_P15"."RID"=:B1 AND "SYS_P15"."PATHID"=HEXTORAW('4972') )
      26 - filter(SYS_XMLI_LOC_ISNODE("SYS_P17"."LOCATOR")=1)
      27 - access("SYS_P17"."RID"=:B1 AND "SYS_P17"."PATHID"=HEXTORAW('745F') )
      29 - filter(SYS_XMLI_LOC_ISNODE("SYS_P19"."LOCATOR")=1)
      30 - access("SYS_P19"."RID"=:B1 AND "SYS_P19"."PATHID"=HEXTORAW('6BA9') )
      32 - filter(SYS_XMLI_LOC_ISNODE("SYS_P21"."LOCATOR")=1)
      33 - access("SYS_P21"."RID"=:B1 AND "SYS_P21"."PATHID"=HEXTORAW('62DB') )
      35 - filter(SYS_XMLI_LOC_ISNODE("SYS_P23"."LOCATOR")=1)
      36 - access("SYS_P23"."RID"=:B1 AND "SYS_P23"."PATHID"=HEXTORAW('1FD9') )
      38 - filter(SYSDATE@!-500<=SYSDATE@!-50)
      41 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
                  "SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)The same query with ORDER BY only on CREATED DESC (takes 15 seconds to complete):
    | Id  | Operation                      | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                                |    15 | 23880 |    31   (0)| 00:00:01 |
    |   1 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |   4 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  5 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    16 |   656 |     5   (0)| 00:00:01 |
    |*  6 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    16 |       |     3   (0)| 00:00:01 |
    |   7 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  8 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    15 |   615 |     4   (0)| 00:00:01 |
    |*  9 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    15 |       |     3   (0)| 00:00:01 |
    |  10 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 11 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 12 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  13 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 14 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 15 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  16 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 17 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 18 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  19 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 20 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 21 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  22 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 23 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 24 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  25 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 26 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 27 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  28 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 29 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     8 |   328 |     4   (0)| 00:00:01 |
    |* 30 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     8 |       |     3   (0)| 00:00:01 |
    |  31 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 32 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 33 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  34 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 35 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 36 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |* 37 |  FILTER                        |                                |       |       |            |          |
    |  38 |   NESTED LOOPS                 |                                |    15 | 23880 |    31   (0)| 00:00:01 |
    |  39 |    TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |    15 |  1350 |    16   (0)| 00:00:01 |
    |* 40 |     INDEX RANGE SCAN DESCENDING| TABLENAME_SC_SUB_IX            |    15 |       |     3   (0)| 00:00:01 |
    |  41 |    TABLE ACCESS BY USER ROWID  | TABLENAME                      |     1 |  1502 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_XMLI_LOC_ISNODE("SYS_P1"."LOCATOR")=1)
       3 - access("SYS_P1"."RID"=:B1 AND "SYS_P1"."PATHID"=HEXTORAW('509D') )
       5 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
       6 - access("SYS_P3"."RID"=:B1 AND "SYS_P3"."PATHID"=HEXTORAW('4FDE') )
       8 - filter(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1)
       9 - access("SYS_P5"."RID"=:B1 AND "SYS_P5"."PATHID"=HEXTORAW('7129') )
      11 - filter(SYS_XMLI_LOC_ISNODE("SYS_P7"."LOCATOR")=1)
      12 - access("SYS_P7"."RID"=:B1 AND "SYS_P7"."PATHID"=HEXTORAW('73C0') )
      14 - filter(SYS_XMLI_LOC_ISNODE("SYS_P9"."LOCATOR")=1)
      15 - access("SYS_P9"."RID"=:B1 AND "SYS_P9"."PATHID"=HEXTORAW('3092') )
      17 - filter(SYS_XMLI_LOC_ISNODE("SYS_P11"."LOCATOR")=1)
      18 - access("SYS_P11"."RID"=:B1 AND "SYS_P11"."PATHID"=HEXTORAW('30AA') )
      20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P13"."LOCATOR")=1)
      21 - access("SYS_P13"."RID"=:B1 AND "SYS_P13"."PATHID"=HEXTORAW('3415') )
      23 - filter(SYS_XMLI_LOC_ISNODE("SYS_P15"."LOCATOR")=1)
      24 - access("SYS_P15"."RID"=:B1 AND "SYS_P15"."PATHID"=HEXTORAW('4972') )
      26 - filter(SYS_XMLI_LOC_ISNODE("SYS_P17"."LOCATOR")=1)
      27 - access("SYS_P17"."RID"=:B1 AND "SYS_P17"."PATHID"=HEXTORAW('745F') )
      29 - filter(SYS_XMLI_LOC_ISNODE("SYS_P19"."LOCATOR")=1)
      30 - access("SYS_P19"."RID"=:B1 AND "SYS_P19"."PATHID"=HEXTORAW('6BA9') )
      32 - filter(SYS_XMLI_LOC_ISNODE("SYS_P21"."LOCATOR")=1)
      33 - access("SYS_P21"."RID"=:B1 AND "SYS_P21"."PATHID"=HEXTORAW('62DB') )
      35 - filter(SYS_XMLI_LOC_ISNODE("SYS_P23"."LOCATOR")=1)
      36 - access("SYS_P23"."RID"=:B1 AND "SYS_P23"."PATHID"=HEXTORAW('1FD9') )
      37 - filter(SYSDATE@!-500<=SYSDATE@!-50)
      40 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
                  "SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)Removing all XmlQueries from the SELECT and adding 1 of them to the XmlTable in the FROM (full table scan, takes 25 seconds to complete):
    | Id  | Operation                    | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                                |  1522 |  2232K| 15515   (3)| 00:03:07 |
    |   1 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    21 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    32 |     2   (0)| 00:00:01 |
    |*  4 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   5 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    23 |     2   (0)| 00:00:01 |
    |*  6 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   7 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    27 |     2   (0)| 00:00:01 |
    |*  8 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   9 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    18 |     2   (0)| 00:00:01 |
    |* 10 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  11 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    13 |     2   (0)| 00:00:01 |
    |* 12 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |* 13 |  TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    37 |     4   (0)| 00:00:01 |
    |* 14 |   INDEX RANGE SCAN           | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |* 15 |  FILTER                      |                                |       |       |            |          |
    |* 16 |   TABLE ACCESS FULL          | TABLENAME                      |  1522 |  2232K|  9423   (4)| 00:01:54 |
    |  17 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    13 |     2   (0)| 00:00:01 |
    |* 18 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  19 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    13 |     2   (0)| 00:00:01 |
    |* 20 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  21 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    21 |     2   (0)| 00:00:01 |
    |* 22 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  23 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    21 |     2   (0)| 00:00:01 |
    |* 24 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("SYS_SXI_7"."RID"=:B1)
       4 - access("SYS_SXI_6"."RID"=:B1)
       6 - access("SYS_SXI_5"."RID"=:B1)
       8 - access("SYS_SXI_4"."RID"=:B1)
      10 - access("SYS_SXI_3"."RID"=:B1)
      12 - access("SYS_SXI_2"."RID"=:B1)
      13 - filter(SYS_XMLI_LOC_ISTEXT("SYS_P0"."LOCATOR","SYS_P0"."PATHID")=1)
      14 - access("SYS_P0"."RID"=:B1 AND "SYS_P0"."PATHID"=HEXTORAW('509D') )
      15 - filter(CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
                  SYS_XQ_PKSQL2XML("SYS_SXI_11"."ORGANIZATION_ID",2,4,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_11" WHERE
                  "SYS_SXI_11"."RID"=:B1),0,0,54525952,0),50,1,2)) AS integer )=6 AND
                  CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT SYS_XQ_PKSQL2XML("SYS_SXI_10"."IS_SENDER",2,4,2)
                  FROM "USERN"."TABLENAME_SC" "SYS_SXI_10" WHERE "SYS_SXI_10"."RID"=:B2),0,0,54525952,0),50,1,2)) AS
                  number(1) )=1 AND CAST(TO_TIMESTAMP(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
                  SYS_XQ_PKSQL2XML("SYS_SXI_9"."CREATION_TIME",180,8,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_9" WHERE
                  "SYS_SXI_9"."RID"=:B3),0,0,20971520,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SSXFF') AS timestamp
                  )>=SYSDATE@!-300 AND CAST(TO_TIMESTAMP(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
                  SYS_XQ_PKSQL2XML("SYS_SXI_8"."CREATION_TIME",180,8,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_8" WHERE
                  "SYS_SXI_8"."RID"=:B4),0,0,20971520,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SSXFF') AS timestamp
                  )<=SYSDATE@!-200)
      16 - filter(EXISTSNODE(SYS_MAKEXML(0,"SYS_ALIAS_11"."SYS_NC00003$"),'/oraxq_defpfx:element1','
                  xmlns:oraxq_defpfx="http://www.example.com/myproject/schema/namespace2"')=1)
      18 - access("SYS_SXI_11"."RID"=:B1)
      20 - access("SYS_SXI_10"."RID"=:B1)
      22 - access("SYS_SXI_9"."RID"=:B1)
      24 - access("SYS_SXI_8"."RID"=:B1)Index creation script:
    CREATE INDEX tabl_xml_ix
      ON tablename(xml)
      INDEXTYPE IS XDB.XMLIndex
      PARAMETERS('
        PATHS (INCLUDE (/element1/common:header/common:kind
    /element1/common:element1Header/common:referenceNumber
    /element1/common:element1Header/common:reference
    /element1/common:element1Header/common:organization/common:organizationId
    /element1/common:element1Header/common:status/common:cStatus
    /element1/common:element1Header/common:status/common:isOpen
    /element1/common:element1Header/common:status/common:processStep
    /element1/common:element1Header/common:status/common:lrrm
    /element1/common:element1Header/common:status/common:sent
    /element1/common:element1Header/common:status/common:success
    /element1/common:element1Header/common:creationTime)
                       NAMESPACE MAPPING (xmlns="http://www.example.com/myproject/schema/namespace2"
                            xmlns:common="http://www.example.com/myproject/schema/common"))');
    ALTER INDEX tabl_xml_ix
    PARAMETERS ('PATHS (INCLUDE ADD (/element1/e/referenceCode
    /element1/e/header/sNumber
    /element1/element2/name
    /element1/element3/name
    /element1/element4/id
    /element1/submission/deferred
    /element1/common:element1Header/common:organization/common:pNumber
    /element1/e/iNumber
    /element1/header/status/aseod
    /element1/common:element1Header/common:isSender
    /element1/ror/gcor
    /element1/header/status/eventReportReceived
    /element1/pod/eNumber)
                       NAMESPACE MAPPING (xmlns="http://www.example.com/myproject/schema/namespace2"
                            xmlns:common="http://www.example.com/myproject/schema/common"))');
    BEGIN
      DBMS_XMLINDEX.registerParameter(
        'tablename_add_sc','ADD_GROUP GROUP tablename_group
    XMLTABLE tablename_sc
    XMLNAMESPACES(
    DEFAULT ''http://www.example.com/myproject/schema/namespace2'',
    ''http://www.example.com/myproject/schema/common'' AS "common"
    ''/element1''
    COLUMNS
    is_sender NUMBER(1) path ''common:element1Header/common:isSender/text()'',
    creation_time TIMESTAMP PATH ''common:element1Header/common:creationTime/text()'',
    rn VARCHAR2(22 CHAR) PATH ''common:element1Header/common:referenceNumber/text()'',
    rc VARCHAR2(21) PATH ''e/referenceCode/text()'',
    reference VARCHAR2(35 CHAR) PATH ''common:element1Header/common:reference/text()'',
    i_nr VARCHAR2(35 CHAR) PATH ''e/iNumber/text()'',
    p_nr VARCHAR2(32) PATH ''common:element1Header/common:organization/common:pNumber/text()'',
    pod_e_nr VARCHAR2(13) PATH ''pod/eNumber/text()'',
    d_id VARCHAR2(16) PATH ''element4/id/text()'',
    organization_id INTEGER PATH ''common:element1Header/common:organization/common:organizationId/text()'',
    sequence_number INTEGER PATH ''e/eHeader/sequenceNumber/text()''
    END;
    ALTER INDEX tabl_xml_ix PARAMETERS('PARAM tablename_add_sc');
    create index tablename_sc_rn_ix on tablename_sc(rn);
    create index tablename_sc_time_ix on tablename_sc(creation_time);
    create index tablename_sc_sub_ix on tablename_sc (organization_id, is_sender, creation_time);Edited by: Michiel Weggen on Apr 11, 2012 2:02 AM Reason: Forgot secondary indexes.
    Edited by: Michiel Weggen on Apr 11, 2012 5:51 AM: changed path of d_id to element4/id in the structured component

  • Weblogic BLOB Cast Exception

    We have an interesting situation where have to support our application on
    both Weblogic 6.1 SP2 using an Oracle Type 2 driver and iPlanet using an
    Oracle Type 4 driver. In our application we are using blob's, and in order
    for our blob's to work with the Type 4 driver we must do a two stage process
    where we insert an Oracle EMPTY_BLOB and then select the newly inserted
    blob, cast it to oracle.sql.BLOB and upload it using streams.
    Unfortunately, when this code runs on WLS the datasource/connection pool
    substitutes some wrapper classes (or something) behind the scenes and we get
    class cast exceptions as the blob is of type
    weblogic.jdbc.rmi.SerialOracleBlob.
    Is there any way to configure WLS connection pools/datasources so that it
    doesn't use any weblogic classes and only uses oracle classes? We currently
    have our 3rd Party Oracle drivers as the first entry in our classpath. We
    can't switch to Oracle Type 2 on iPlanet (too buggy), or this would all be
    moot and we'd simply use the more generic non-vendor specific way of
    uploading blob's. And we can't cast to weblogic classes, because then that
    would break on iPlanet.
    Here's the code snippet that we can't change, because we have to support
    Oracle Type 4 on iPlanet.
    ResultSet blobs = ustmt.executeQuery();
    blobs.next();
    Blob blob = blobs.getBlob(1);
    OutputStream blobOut = ((oracle.sql.BLOB)
    blob).getBinaryOutputStream();
    try {
    blobOut.write(attachment.getFile());
    } catch (IOException e) {
    throw new ServletException(e);
    } finally {
    try {
    blobOut.close();
    } catch (IOException e) {
    throw new ServletException(e);
    blobs.close();
    Thanks,
    Gary

    Hi Gary!
    Blob oracle extensions are implemented internally in weblogic as
    weblogic.jdbc.rmi.SerialOracleBlob. As we wrap objects internally for
    serialization purpose, we can not use oracle objects directly. So, you have to
    use SerialBlob in weblogic.
    Mitesh
    Gary Rudolph wrote:
    We have an interesting situation where have to support our application on
    both Weblogic 6.1 SP2 using an Oracle Type 2 driver and iPlanet using an
    Oracle Type 4 driver. In our application we are using blob's, and in order
    for our blob's to work with the Type 4 driver we must do a two stage process
    where we insert an Oracle EMPTY_BLOB and then select the newly inserted
    blob, cast it to oracle.sql.BLOB and upload it using streams.
    Unfortunately, when this code runs on WLS the datasource/connection pool
    substitutes some wrapper classes (or something) behind the scenes and we get
    class cast exceptions as the blob is of type
    weblogic.jdbc.rmi.SerialOracleBlob.
    Is there any way to configure WLS connection pools/datasources so that it
    doesn't use any weblogic classes and only uses oracle classes? We currently
    have our 3rd Party Oracle drivers as the first entry in our classpath. We
    can't switch to Oracle Type 2 on iPlanet (too buggy), or this would all be
    moot and we'd simply use the more generic non-vendor specific way of
    uploading blob's. And we can't cast to weblogic classes, because then that
    would break on iPlanet.
    Here's the code snippet that we can't change, because we have to support
    Oracle Type 4 on iPlanet.
    ResultSet blobs = ustmt.executeQuery();
    blobs.next();
    Blob blob = blobs.getBlob(1);
    OutputStream blobOut = ((oracle.sql.BLOB)
    blob).getBinaryOutputStream();
    try {
    blobOut.write(attachment.getFile());
    } catch (IOException e) {
    throw new ServletException(e);
    } finally {
    try {
    blobOut.close();
    } catch (IOException e) {
    throw new ServletException(e);
    blobs.close();
    Thanks,
    Gary

  • [Execute SQL Task] Error: Executing the query "DECLARE_@XMLA nvarchar(3000) ,__@DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,

    Hi
    DECLARE @XMLA nvarchar(3000)
    , @DateSerial nvarchar(35);
    -- Change date to format YYYYMMDDHHMMSS
    SET @DateSerial = CAST(GETDATE() AS DATE);
    --SELECT @DateSerial
    Set @XMLA = 
    N' <Batch xmlns="http://schemas.microsoft.com/analysis services/2003/engine">
     <ErrorConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
    xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200"
    xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200">
    <KeyErrorLimit>-1</KeyErrorLimit>
    <KeyNotFound>IgnoreError</KeyNotFound>
    <NullKeyNotAllowed>IgnoreError</NullKeyNotAllowed>
     </ErrorConfiguration>
     <Parallel>
    <Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2"
    xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200"
    xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
     <Object>
     <DatabaseID>MultidimensionalProject5</DatabaseID>
     <CubeID>giri</CubeID>
     <MeasureGroupID>Fact Internet Sales</MeasureGroupID>
     </Object>
     <Type>ProcessFull</Type>
     <WriteBackTableCreation>UseExisting</WriteBackTableCreation>
     </Process>
      </Parallel>
    </Batch>';
    EXEC (@XMLA) At SHALL-PCAdventureWorksDw ;
     iam executive the    query when iam getting below error.
      [Execute SQL Task] Error: Executing the query "DECLARE
    @XMLA nvarchar(3000)
    , @DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set
    correctly, or connection not established correctly. 
     how to solve this error;
     please help me

    What are you trying to do? What sort of data source is  SHALL-PCAdventureWorksDw?
    When you use EXEC() AT, I would execpt to see an SQL string to be passed to EXEC(), but you are passing an XML string????
    If you explain why you think this would work in the first place, maybe we can help you.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Need to obtain updateable ResultSet via call to PL/SQL function

    I'm using JDBC and the Oracle JDBC driver to call a PL/SQL function that returns a SYS_REFCURSOR. I do this via a CallableStatement object and then cast the output parameter to a ResultSet object. However, I want this ResultSet object I end up with to be updateable. The following code throws an exception stating "Invalid operation for read only resultset: updateString ":
    cstmt2 = con.prepareCall("{? = call get_upload_entry_for_update(?)}",
                             ResultSet.TYPE_FORWARD_ONLY,
                             ResultSet.CONCUR_UPDATABLE);
    cstmt2.registerOutParameter(1, OracleTypes.CURSOR);
    cstmt2.setInt(2, newUploadId);
    cstmt2.execute();
    rs = (ResultSet) cstmt2.getObject(1);
    rs.next();
    rs.updateString("UPLOAD_FILENAME", fileName);
    // . . .So even though, I create the CallableStatement such that ResultSets should be updateable, it's not allowing me to do any updates. Also, in case you're wondering, inside the PL/SQL function, the query on which the cursor is based is a select statement which does specify "for update" at the end.
    I can get it to work as follows using a Statement object that executes the SELECT statement directly instead of a CallableStatement that executes a PL/SQL function:
    Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    rs = stmt.executeQuery("select UPLOAD_FILENAME, UPLOAD_FILE from rf_upload where upload_id = "+newUploadId+" for update");
    rs.next();
    rs.updateString("UPLOAD_FILENAME", fileName);
    //. . . Although this works, the project I'm working has a goal to encapsulate all SQL into Functions and Stored Procedures so I'd like to get it working that way instead.
    So the bottom-line question is: Using the Oracle JDBC driver, how can I call a PL/SQL function in such a way that I can obtain an updateable ResultSet object?
    Thanks for any suggestions. I'd be happy to clarify anything that's unclear.

    Hmmm...
    I'm still scratching my head about this one, just not sure it's doable, but I'll point out something, maybe it will give you a clue...
    In your code, you have:
    cstmt2 = con.prepareCall("{? = call get_upload_entry_for_update(?)}",
                             ResultSet.TYPE_FORWARD_ONLY,
                             ResultSet.CONCUR_UPDATABLE);I don't think the ResultSet parameters do anything towards your goal of getting an updatable result set via the returned cursor, those parameters affect the result set produced if you were to call:
    ResultSet rs2 = cstmt2.executeQuery();and not the result set generated by:
    rs = (ResultSet) cstmt2.getObject(1);Futhermore, while the "FOR UPDATE" is almost certainly something you want to do, it also doesn't affect the cursor (I think) but merely locks the affected rows in the DB.
    You might try calling rs.getType() and rs.getConcurrency() on the ResultSet you get from getObject, though I suspect they'll merely confirm the bad news that the cursor your getting back isn't right...
    You also might try the Oracle-specific getCursor call:
    rs = ((OracleCallableStatement)cstmt2).getCursor (1)instead of getObject, though I don't think it will help...
    I've been curious enough to dig around through most of my handy references and Oracle's docs and MetaLink and come up mostly empty, although almost 5 years ago Oracle Support said:
    " Reference Cursors from a pl/sql stored procedure are not updateable in any language."

  • Casting an (deserialized) Object as a (custom) subclass.

    Haigh,
    I'm having trouble casting objects as their subclass.
    I'll explain, i have a class that fetches a stored serialized object from a Database.
    i can store the objects no problem.
    ex. oodb.store(new Machine());
    // machine being my custom class that stores information on the running machine (OS,JVM,ip and MAC address etc.)
    then when i want to retrive the object
    it should work with the method getObjectByID(int idOfObject) which returns an Object
    ex. oodb.getObjecyByID(7)
    then i create a new instance of machine
    Machine computer = (Machine) oodb.getObjectByID(7);
    but i get an error saying i cant cast Object (java.lang.Object) as a Machine (ie.iconicaelixia.objects.Machine to be exact)
    It worked before!
    well a variation of it worked, then i changed the testing class to suit another test.
    i've tried the if(Object intanceOf Machine) method aswell, but it never returned true. Eventhough the binary read of the stored object clearly states it is.
    Also, on the topic of serialized objects in a database, would it be more effective if my store/fetch methods stored/fetched Class(es) instead of Object(s)?
    If so, how would i return a Class?
    For Reference here is my Store/Fetch Methods:
    public void storeObject(String ClassType,Object ObjectToStore,String indexableInfo)
              try
                   indexableInfo = indexableInfo + "$ObjCreated="+new Date().toString();
                   if(ClassType==null)
                        ClassType = ObjectToStore.getClass().getName();
                   int oID = getAvailableID();
                   PreparedStatement ps = nasc.nasc().prepareStatement("Insert into iserv.objects Set OID = ?,Class = ?, Object = ?,Indexable = ? ");
                   ps.setInt(1,oID);
                   ps.setString(2,ClassType);
                   ps.setObject(3,ObjectToStore);
                   ps.setString(4,indexableInfo);
                   ps.execute();
                   ps = null;
              catch (SQLException sqle)
                   sqle.printStackTrace();
         public Object getObjectByID(int ObjectID)
              Object rO = null;
              try
                   PreparedStatement ps = nasc.nasc().prepareStatement("SELECT OID, OBJECT from iServ.Objects WHERE OID = "+ObjectID);
                   ResultSet rs = ps.executeQuery();
                   rs.next();
                   rO = rs.getObject("OBJECT");
                   LastRetrvID = rs.getInt("OID");
                   rs.close();
                   ps = null;
              catch (SQLException sqle)
                   sqle.printStackTrace();
              return rO;
         }Gurbh Míle síle as aon cabhair!

    Okay, I'll ask the obvious question:
    Why are you trying to store serialized objects? Why not use the usual approach to a relational database, break down the information into attributes and store them in appropriate fields?

Maybe you are looking for

  • Get data from a JMS XML queue and save it in a file

    Hi, Here I come with my issue again. I'm trying to test a JMS XML implementation with ODI 10.1.3.4.0 and my target is a single delimited file. I made simple things, my XML contains the following code : +<?xml version="1.0" encoding="UTF-8"?>+ +<test>

  • Upgrading from tiger 10.4.11 to leopard without a cd drive?

    Is there any way to upgrade to leopard when my cd drive is broken? I know that apple has new downloadable versions of Os lion to download from the app store but is there such a thing for leopard? Please help i cannot sync my iphone to my computer????

  • Date show in dd/mm/yyyy format

    hey.....my database generates date in xml in following format <date>1993-02-27T00:00:00+05:30</date> i wish to show and sort this date in the form 27-02-93 how can i do it?

  • How to limit total user's traffic?

    Hello. How can I limit user's traffic? Access policy has only "object max size".

  • 2 cons units - Comp & PC

    Hi guys, I have Company set up as a Consolidation Unit...Also need to set up Profit Center as Consolidation Unit 1) Is this the right method...why if no 2) if yes, then what are the steps to implement it Thanks