ResultSet Issues

I have a servlet that queries a database, puts the data into a 2-D String array, and then forwards this array to a JSP page to display it in a table. The problem is that the table is showing rows 5 through 19 rows (of 19 total rows) and then 4 rows of nulls. I'm guessing that when I am entering the data into the array, I am starting at the fifth row in the ResultSet although I don't know why.
Here are two portions of the Servlet code:
               Statement stmt = con.createStatement(
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                 ResultSet.CONCUR_READ_ONLY);
               ResultSet rs = stmt.executeQuery(query);
               rows = -1;
               if (rs.last())
                    rows = rs.getRow();
                    rs.first();
// not at first row here for some reason??
               int columns = 6;
               data = new String[rows][columns];
               for(int i = 0; i < rows; i++)
                    data[0] = rs.getString("REDEEM_STATUS");
                    data[i][1] = "folio name";
                    data[i][2] = "checkout";
                    data[i][3] = rs.getString("RDM_CERTNO");
                    data[i][4] = rs.getString("RDM_NUM_OF_NTS");
                    data[i][5] = rs.getString("AMOUNT");
                    rs.next();
          String [][] table = getTable(approve, property);
          request.setAttribute("TABLE", table);
          request.setAttribute("ROWS", new Integer(rows));
          ServletContext context = getServletContext();
          RequestDispatcher dispatcher = context.getRequestDispatcher("/output.jsp");
          dispatcher.forward(request, response);
This is part of the JSP code:
<%
String output[][] = (String[][])request.getAttribute("TABLE");
Integer rows = (Integer)request.getAttribute("ROWS");
int columns = 6;
for(int i = 0; i < rows.intValue(); i++ )
%>
<TR><TD><FORM ACTION="com.Select">
<INPUT TYPE=SUBMIT NAME="button" VALUE="Select">
</FORM></TD>
<%
for(int j = 0; j < columns; j++ )
     s = output[i][j];
%>
<TD><%= s %></TD>
<%
%>
</TR>
<%
%>

You use a sort of non-traditional method of reading the result set, which probably requires the database driver to traverse it twice instead of once. What's wrong with the traditional way?ResultSet rs = stmt.executeQuery(query);
rows = 0;
while (rs.next()) {
  data[rows][0] = ...
  // and so on
  rows ++;
}That's unlikely to be the source of your stated problem, but who knows? You are complaining about the contents of the String[][] named "table", correct? And it's generated by some code you didn't post that doesn't take that "data" array as a parameter. It's quite possible that the problem is there.

Similar Messages

  • Resultset issue

    Hi,
    I am trying to execute a query and use the resultset as below:
    Connection con = ConnectionManager.getConnection(); st = (Statement)con.createStatement(); rs = st.executeQuery("SELECT DISTINCT ENV_DETAILS1.* , RELEASE_STATUS.RELEASE_NAME, BUILD_DETAILS.RELEASE_ID FROM ENV_DETAILS1,RELEASE_STATUS,BUILD_DETAILS WHERE (ENV_DETAILS1.ENV_ID='5' AND ENV_DETAILS1.RELEASE_ID='2') AND (ENV_DETAILS1.STATUS='active') AND (ENV_DETAILS1.RELEASE_ID=BUILD_DETAILS.RELEASE_ID) AND (RELEASE_STATUS.RELEASE_ID=BUILD_DETAILS.RELEASE_ID)"); //ResultSetMetaData rsmd = rs.getMetaData(); //int numberOfColumns = rsmd.getColumnCount(); //this correctly gives the expected number of columns while (rs.next()) { //not reaching here //get values from resultset int envIdQ=rs.getInt("Env_id"); .. .. }
    When I test the same query in SQLDeveloper(1.5.4), it is executing fine and I get the result. But in the code above "rs.next()" is returning false. I am using Weblogic 10.3, ojdbc6.jar and Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production. I am using the Weblogic datasource to get the connection and there seem to be no issue with that as I can execute other queries properly and get expected results. I am not able to figure out that what could be wrong in the above code. It would be great help if anyone can suggest something.
    Thanks in advance.

    Welcome to the forum!
    >
    When I test the same query in SQLDeveloper(1.5.4), it is executing fine and I get the result. But in the code above "rs.next()" is returning false.
    >
    Then, as already suggested, that means there is no result set 'for that query, by that user, on that database'.
    So since you know there must be something different you need to find out what the difference is.
    To identify the user add code to query the user from the database
    SELECT USER FROM DUAL;If the user is the same then add code to query the database information
    select name, created, platform_id, platform_name, db_unique_name from v$databaseOne of those queries will give you a difference.
    You can also use the 'getmetaData' method on the connection instance to get a DatabaseMetaData instance and then query it to get database specific information.
    http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/DatabaseMetaData.html

  • Comapring Records in ResultSet  ,Issue of Performance

    Hi,
    i got a Table on which I am calling select ,and getting the resultset as in which some of the rows will Have first column value as same ,but subsequent columns may have data or null Values.I want to club all the values for same First Column Value.I did it like that in java,but is it cab done in Oracle Procedures it self.
    Any analysis of this code and Database Loops ideas would be helpful.
    esultSetMetaData rsd = Rs2.getMetaData();
    int n = rsd.getColumnCount();
    Vector val = new Vector(n);
    Vector val2 = new Vector(n);
    System.out.println("No Of Columns--"+n);
    while(Rs2.next())
         if(Rs2.isFirst())
              for(int l=1;l<=n;l++)
              val.add(l-1,(Object)Rs2.getString(l));
         else
                   for(int j=1;j<=n;j++)
              val2.add(j-1,(Object)Rs2.getString(j));
                   if(val2.get(0).toString().equals(val.get(0).toString()))
                             System.out.println("same orderheaderid"+val2.get(0).toString());
                             i--;
                             for(int k=1;k<=n;k++)
                             if(val.get(k-1)==null)
                                  if(val2.get(k-1)!=null)
                                  val.set(k-1,val2.get(k-1));
                             val2.clear();
                             if(Rs2.isLast())
                                  for(int l=1;l<=n;l++)
                                       System.out.println(val.get(l-1));
                             else
                        else
                   {          System.out.println("different if"+val.get(0));
                             for(int f=1;f<=n;f++)
                                  System.out.println(f-1+"------"+val.get(f-1));
                        System.out.println("Count Value is--"+i);
                        val.clear();
                        val =(Vector)val2.clone();
                        if(Rs2.isLast())
                             for(int r=1;r<=n;r++)
                                  System.out.println(val2.get(r-1));
                        else
                             for(int s=1;s<n;s++)
                                  val.set(s-1,val2.get(s-1));
                        val2.clear();
                        val2 = (Vector)val.clone();
              }i++;
              //z++;
    Rs2.close();
    Thank u
    Vasu

    Double post:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=544516&tstart=0&trange=15
    http://forum.java.sun.com/thread.jsp?forum=48&thread=544517&tstart=0&trange=15
    Sounds like it breaks the rules for first normal form to me:
    http://databases.about.com/library/weekly/aa081901a.htm

  • SDO_UTIL.FROM_KMLGEOMETRY and Java

    Hello,
    I'm trying to write a Java program that will parse a KML file, convert KML geometry coordinates into SDO_GEOMETRY coordinates, then insert appropriate records into the database.
    I'm stuck on the 2nd part, converting KML into SDO_GEOMETRY. Here's my code:
    private static void getSDOGeom(Connection con, String [] geomKML, JGeometry [] geomSDO) throws Exception {
    CallableStatement s = con.prepareCall("{? = call SDO_UTIL.FROM_KMLGEOMETRY(?)}");
    ResultSet rs = null;
    for (int i = 0; i < geomKML.length; i++) {
    s.registerOutParameter(1, JGeometry.GTYPE_POINT);
    s.setString(2, "\'<Point><coordinates>" + geomKML[i] + "</coordinates></Point>\'");
    rs = s.executeQuery();
    geomSDO[i] = (JGeometry) s.getObject(1);
    Here's my error message:
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    -then stack trace saying which line of my program caused the error - the executeQuery line.
    It looks like my problem is from the JGeometry.GTYPE_POINT in the registerOutParameter method call. I've tried a number of items here to no effect. The geomKML array contains KML coordinates stripped from a KML/XML file, I had to put the <Point> and <coordinates> tags in because the XML parser isn't including them. I've converted coordinates directly in the database, so I know the KML input is correct. The geomSDO array is of the proper size, but is null. I'm not sure what I'm doing wrong and can't find anything like this in the forums. A DB guy here at work did some searching and said I should use JGeometry, but he's not sure why it isn't working either.
    Anyone have any ideas?

    Thanks for the help... my problem was the ResultSet. I didn't noticed until your most recent code example that you weren't using it, but were acting upon the CallableStatement directly for the getObject method. I was using CallableStatement wrong. I think I saw an example somewhere with the CallableStatement and the ResultSet both being used. Thanks for the STRUCT code too, I saw something about that in a forum post, but wasn't sure what it was doing... but my code doesn't work without it. I did have to track down the jar libraries and imports for STRUCT and OracleType, but that wasn't too difficult.
    As to your other points, there is a bit of a misunderstanding because of the limited information I posted - I should have been more clear. This method is one method in a larger program - my database connection was already set up and working, though I thank you for being proactive and including it just in case. I was also printing out my KML coordinates to check to make sure they were ok and had already tested them in the database with a written procedure and knew they were working. The "\" was an escape character for a single quote, which I thought I needed to include because the input to FROM_KMLGEOMETRY needed to be surrounded by single quotes in the database testing. Your initial response also included them. I found that by removing them, my error went away - in fact, I didn't even notice they were there at first. Finally, the JGeometry array does indeed work and the array list isn't needed. I was hoping the array would work as it's more light weight and I'm able to pass the object by reference instead of by value, decreasing the overhead of my code. I was delighted to find that it did work once I fixed the ResultSet issue as previously mentioned. It is initialized elsewhere in my code to be the same size as the array with the KML geometry.
    I don't add the comments above to rebuff you. I'm very glad to you provided extremely complete answers. You've helped me before. I add them in case someone else stumbles upon this thread in hopes that the information will be useful to them.
    For posterity, Final code with related imports:
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import oracle.spatial.geometry.JGeometry;
    import oracle.jdbc.OracleTypes;
    import oracle.sql.STRUCT;
    private static void getSDOGeom(Connection con, String [] geomKML, JGeometry [] geomSDO) throws Exception {
    CallableStatement s = con.prepareCall("{? = call SDO_UTIL.FROM_KMLGEOMETRY(?)}");
    STRUCT geomSDO_STRUCT = null;
    for (int i = 0; i < geomKML.length; i++) {
    s.registerOutParameter(1, OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
    // You could also add extrude, tessellate and altitudeMode
    s.setString(2, "<Point><extrude>0</extrude><tessellate>0</tessellate>" +
    "<altitudeMode>clampToGround</altitudeMode><coordinates>" + geomKML[i] +
    "</coordinates><extrude>0</extrude><tessellate>0</tessellate>" +
    "<altitudeMode>clampToGround</altitudeMode></Point>");
    s.executeQuery();
    geomSDO_STRUCT = (STRUCT) s.getObject(1);
    geomSDO[i] = JGeometry.load(geomSDO_STRUCT);
    s.close();
    The libraries that I needed to add to the project at compile time (already had the jdbc driver loaded for runtime) are
    sdoapi.jar (this is for JGeometry and other spatial related items) located <oracle home>/md/jlib/
    ojdbc6.jar (this is where the STRUCT and OracleTypes are found) located <oracle home>/jdbc/lib/
    Thanks,
    Edit:
    If you're trying to write SDO_GEOMETRY to a database, this thread will help.
    ORA-00939: too many arguments for function
    Edited by: J-rd-n on Sep 14, 2010 11:44 AM

  • How do I handle large resultsets in CRXI without a performance issue?

    Hello -
    Problem Definition
    I have a performance problem displaying large/huge resultset of data on a crystal report.  The report takes about 4 minutes or more depending on the resultset size.
    How do you handle large resultsets in Crystal Reports without a performance issue?
    Environment
    Crystal Reports XI
    Apache WebSvr 2.X, Jboss 4.2.3, Struts
    Java Reporting Component (JRC),Crystal Report Viewer (CRV)
    Firefox
    DETAILS
    I use the CRXI thick client to build my report (.rpt) and then use it in my webapplication (webapp) under Jboss.
    User specifies the filter criteria to generate a report (date range etc) and submits the request to the webapp.  Webapp  queries the database, gets a "resultset".
    I initialize the JRC and CRV according to all the specifications and finally call the "processHttpRequest" method of Crystal Report Viewer to display the report on browser.
    So.....
    - Request received to generate a report with a filter criteria
    - Query DB to get resultset
    - Initialize JRC and CRV
    - finally display the report by calling
        reportViewer.processHttpRequest(request, response, request.getSession().getServletContext(), null);
    The performance problem is within the last step.  I put logs everywhere and noticed that database query doesnt take too long to return resultset.  Everything processes pretty quickly till I call the processHttpRequest of CRV.  This method just hangs for a long time before displaying the report on browser.
    CRV runs pretty fast when the resultset is smaller, but for large resultset it takes a long long time.
    I do have subreports and use Crystal report formulas on the reports.  Some of them are used for grouping also.  But I dont think Subreports is the real culprit here.  Because I have some other reports that dont have any subreports, and they too get really slow displaying large resultsets.
    Solutions?
    So obviously I need a good solution to this generic problem of "How do you handle large resultsets in Crystal Reports?"
    I have thought of some half baked ideas.
    A) Use external pagination and fetch data only for the current page being displayed.  But for this, CRXI must allow me to create my own buttons (previous, next, last), so I can control the click event and fetch data accordingly.  I tried capturing events by registering event handler "addToolbarCommandEventListener" of CRV.  But my listener gets invoked "after" processHttpRequest method completes, which doesnt help.
    Some how I need to be able to control the UI by adding my own previous page, next page, last page buttons and controlling it's click events. 
    B) Automagically have CRXI use a javascript functionality, to allow browser side page navigation.  So maybe the first time it'll take 5 mins to display the report, but once it's displayed, user can go to any page without sending the request back to server.
    C) Try using Crystal Reports 2008.  I'm open to using this version, but I couldnt figureout if it has any features that can help me do external pagination or anything that can handle large resultsets.
    D) Will using the Crystal Reports Servers like cache server/application server etc help in any way?  I read a little on the Crystal Page Viewer, Interactive Viewer, Part Viewer etc....but I'm not sure if any of these things are going to solve the issue.
    I'd appreciate it if someone can point me in the right direction.

    Essentialy the answer is use smaller resultsets or pull from the database directly instead of using resultsets.

  • Issue with a resultSet.wasNull() method

    Hello all
    I'm having a small issue with a resultset, basically i wanna test if it returns a null value but it does not seems to work.
    Its a simple application that pulls football matches data out of a database base on the provided data.
    This is my code, i would like to first say that, connectivity works fine, database existing, tables existing, if correct data's are inserted the application fetches the data with no problem.
    public void getMatch(GregorianCalendar cal){
    java.sql.Date sqlDate= new java.sql.Date(cal.getTimeInMillis());
    try{
    String resultMatch="SELECT resultMatch FROM matches WHERE date=?";
    PreparedStatement pre=connection.prepareStatement(resultMatch);
    pre.setDate(1,sqlDate);
    ResultSet resMatch=pre.executeQuery();
    if(resMatch.wasNull()){
    System.out.println("No data found");
    } else {
    System.out.println("Show all datas");
    }//rest of code
    } catch(SQLException e){
    }//rest of code
    the problem arises now, if i enter a data that its in the DB, its fine, all data's are pulled out and printed (via while(resMatch.next()........))
    If i enter a non existing data....nothing comes out, not even an exception.
    Any advice?
    Thx

    enrico wrote:
    This is my code, i would like to first say that, connectivity works fine, database existing, tables existing, if correct data's are inserted the application fetches the data with no problem.The code posted does not do that.
    >
    public void getMatch(GregorianCalendar cal){
    java.sql.Date sqlDate= new java.sql.Date(cal.getTimeInMillis());
    try{
         String resultMatch="SELECT resultMatch FROM matches WHERE date=?";
         PreparedStatement pre=connection.prepareStatement(resultMatch);
    pre.setDate(1,sqlDate);
         ResultSet resMatch=pre.executeQuery();
    if(resMatch.wasNull()){There is no way that the above code returns 'data' from the database.
    A result set represents a collection of zero or more rows.
    One must first retrieve a row before doing anything with it.
    The above code does not call next() so it absolutely does not retrieve any rows.
    The JDBC tutorial might help.
    http://download.oracle.com/javase/tutorial/jdbc/basics/

  • Resultset.next() Issue

    Okay I have narrow my issue down to activity involved with the resultset.next() method. What is happening is I am working through a small resultset--3 records. These records are made up of columns from 3 seaprate tables (9 total). Some of these tables have many records (> 3K) in them. I moved the SQL statement in a store procedure so we can execute the query in a faster manner. The store procedure is returning the information in only 46ms. However, when I start looking through the resultset on the app server, it is taking 19K ms for the first time through the loop.
    I am at a lost to explain why the first iteration is taking so long. I have looked back at the SQL statement. I use alias names for the tables. I identify the column names in the select statement, but I do not use aliases for the column names. I am wondering if my problem is connected to the fact that the Oracle Driver
    maybe going back to get the column names the first time through the result set. I am not using the column name to index into the resultset. If my theory is right, this would explain the high latency. If I am wrong, I am stumped.
    Any suggestions or help explaining this would be greatly appreciated.
    As always, thanks for reading my post.
    Russ

    Execution of a CallableStatement (Procedure) is relatively fast. Getting ResultSet back is fast. But First iteration over the result set takes a lot of time comparing to the following iterations.
    Part of the code :
    long start=System.currentTimeMillis();
    int i=0;
    long local=System.currentTimeMillis();
    while(rs.next()){
    if (i==0){
    MetricsUtil.printTime("ResultSetRowHolder.getRows(ResultSet rs) ["+list.size()+" ]",local);
    local=System.currentTimeMillis();
    hol=new ResultSetRowHolder(rs);
    list.add(hol);
    i++;
    if (i%100==0){
    MetricsUtil.printTime("ResultSetRowHolder.getRows(ResultSet rs) ["+list.size()+" ]",local);
    local=System.currentTimeMillis();
    MetricsUtil.printTime("ResultSetRowHolder.getRows(ResultSet rs) ["+list.size()+" ]",start);
    Printouts
    Metrics << QueryHelper.executeStatement() >> Total time -> 2.836 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [0 ] >> Total time -> 13.867 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [100 ] >> Total time -> 0.48 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [200 ] >> Total time -> 0.44 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [300 ] >> Total time -> 0.47 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [400 ] >> Total time -> 0.38 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [500 ] >> Total time -> 0.37 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [600 ] >> Total time -> 0.38 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [700 ] >> Total time -> 0.35 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [800 ] >> Total time -> 0.34 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [900 ] >> Total time -> 0.32 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1000 ] >> Total time -> 0.34 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1100 ] >> Total time -> 0.41 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1200 ] >> Total time -> 0.32 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1230 ] >> Total time -> 14.340 sec

  • JSP - Bean - Scope Issue with ResultSet

    Hi there,
    I have a JSP page that uses a Bean to get ResultSets from a db. My methods return ResultSets, but they seem to get out of scope on the JSP page when I try to use them. I'm not sure why. I have included 2 snippets below one that works and one that doesn't. I get a java.lang.null exception when the page is run. Not sure how or why the variable seems to go out of scope? I can work around it, but I would rather find out why this is happening.
    This one fails:
    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    try{
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <%
    ResultSet roem = lookup.getOEMDropdown();
    //open db conn
    lookup.openIlprod();
    if(roem!=null){
    %>
    OEM:  
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){     
         //log to Tomcat
    %>
    This one works....why??
    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    try{
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <%
    //open db conn
    lookup.openIlprod();
    ResultSet roem = lookup.getOEMDropdown();
    if(roem!=null){
    %>
    OEM:  
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){     
         //log to Tomcat
    %>

    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    String ilprod_db_user;
    String ilprod_db_pass;
    String tedsi_prod_owner;
    String nsp_portal_owner;
    String iladmin_owner;
    String ilprod_db_host;
    String ilprod_db_port;
    String ilprod_db_service;
    try{
         //get the ilprod_db_user from the deployment descriptor
         ilprod_db_user = (String)getServletContext().getInitParameter("ilprod_db_user");
         //ensure a value is present
         if(ilprod_db_user==null||ilprod_db_user.equals("")){
         throw new ServletException("Error retrieving ilprod_db_user from deployment descriptor. - ilprod_db_user is null or an empty string");
         //get the ilprod_db_pass from the deployment descriptor
         ilprod_db_pass = (String)getServletContext().getInitParameter("ilprod_db_pass");
         //ensure a value is present
         if(ilprod_db_pass==null||ilprod_db_pass.equals("")){
         throw new ServletException("Error retrieving ilprod_db_pass from deployment descriptor. - ilprod_db_pass is null or an empty string");
         //get the tedsi_prod_owner from the deployment descriptor
         tedsi_prod_owner = (String)getServletContext().getInitParameter("tedsi_prod_owner");
         //ensure a value is present
         if(tedsi_prod_owner==null||tedsi_prod_owner.equals("")){
         throw new ServletException("Error retrieving tedsi_prod_owner from deployment descriptor. - tedsi_prod_owner is null or an empty string");
         //get the nsp_portal_owner from the deployment descriptor
         nsp_portal_owner = (String)getServletContext().getInitParameter("nsp_portal_owner");
         //ensure a value is present
         if(nsp_portal_owner==null||nsp_portal_owner.equals("")){
         throw new ServletException("Error retrieving nsp_portal_owner from deployment descriptor. - nsp_portal_owner is null or an empty string");
         //get the iladmin_owner from the deployment descriptor
         iladmin_owner = (String)getServletContext().getInitParameter("iladmin_owner");
         //ensure a value is present
         if(iladmin_owner==null||iladmin_owner.equals("")){
         throw new ServletException("Error retrieving iladmin_owner from deployment descriptor. - iladmin_owner is null or an empty string");
         //get the ilprod_db_host from the deployment descriptor
         ilprod_db_host = (String)getServletContext().getInitParameter("ilprod_db_host");
         //ensure a value is present
         if(ilprod_db_host==null||ilprod_db_host.equals("")){
         throw new ServletException("Error retrieving ilprod_db_host from deployment descriptor. - ilprod_db_host is null or an empty string");
         //get the ilprod_db_port from the deployment descriptor
         ilprod_db_port = (String)getServletContext().getInitParameter("ilprod_db_port");
         //ensure a value is present
         if(ilprod_db_port==null||ilprod_db_port.equals("")){
         throw new ServletException("Error retrieving ilprod_db_port from deployment descriptor. - ilprod_db_port is null or an empty string");
         //get the ilprod_db_service from the deployment descriptor
         ilprod_db_service = (String)getServletContext().getInitParameter("ilprod_db_service");
         //ensure a value is present
         if(ilprod_db_service==null||ilprod_db_service.equals("")){
         throw new ServletException("Error retrieving ilprod_db_service from deployment descriptor. - ilprod_db_service is null or an empty string");
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <jsp:setProperty name="lookup" property="ilprod_db_user" value="<%=ilprod_db_user%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_pass" value="<%=ilprod_db_pass%>"/>
    <jsp:setProperty name="lookup" property="tedsi_prod_owner" value="<%=tedsi_prod_owner%>"/>
    <jsp:setProperty name="lookup" property="nsp_portal_owner" value="<%=nsp_portal_owner%>"/>
    <jsp:setProperty name="lookup" property="iladmin_owner" value="<%=iladmin_owner%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_host" value="<%=ilprod_db_host%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_port" value="<%=ilprod_db_port%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_service" value="<%=ilprod_db_service%>"/>
    <%
    //open db conn
    lookup.openIlprod();
    ResultSet roem = lookup.getOEMDropdown();
    ResultSet rstat = lookup.getStatusDropdown();
    if(roem!=null){
    %>
    OEM:��
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    //******* IF I PUT ResultSet IN FRONT OF rstat HERE IT WORKS FINE?
    rstat = lookup.getStatusDropdown();
    if(rstat!=null){
    %>
    Status:��
    <select name="status">
    <%
    while(rstat.next()){
    %>
    <option value="<%=rstat.getString("id")%>"><%=rstat.getString("description")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("Status:  no records<br><br>");
    //close db conn
    lookup.closeIlprod();
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){
         //set request attributes to pass to error page
         request.setAttribute("javax.servlet.error.exception",e);
         request.setAttribute("javax.servlet.error.message",e.getMessage());
         request.setAttribute("javax.servlet.error.request_uri",     request.getRequestURI());
         request.setAttribute("javax.servlet.error.servlet_name", request.getServletPath());
         //log to Tomcat
         application.log(" Message: "+e.getMessage()+'\r'+'\n'+"RequestURI: "+request.getRequestURI()+'\r'+'\n'+"Servlet Path: "+request.getServletPath(),e);
         //forward to the error page
         RequestDispatcher rd =     request.getRequestDispatcher("error.jsp");
         rd.forward(request,response);
         //out.println(e.getMessage());
    %>

  • String allocation in ResultSet::getString() issue

    Hi all :)
    I have been learning the basics of OCCI and I am having a
    problem with Debug mode in MSVC. When I retrieve a string from
    ResultSet::getString, and the string goes out of scope, I get an
    assert about an invalid heap pointer.
    I think that somehow the ResultSet object is setting the pointer
    inside of the string object in a way which would circumvent the
    list of allocations on the debug heap. So that when the string
    destructor is called, it tries to free the internal pointer, and
    asserts.
    Everything works correctly in Release mode.
    Is there any suggested way of handling this? Or is there a debug
    version of the OCCI?
    Here is the simplistic offending code:
    while (rs->next())
    string username = rs->getString(1);
    string passwd = rs->getString(2);
    } <--- asserts here
    Any help would be great :)
    Thanks,
    Gerald Fishel

    OCCI has multiple copies of libraries that work with different compiler versions. Please make sure you are using the appropriate version of dll. You can search for this topic on OCCI forum.
    C++ Call Interface (OCCI)

  • The issue about the ResultSet.TYPE_SCROLL_INSENSITIVE

    my database is oracle ,the oracle charset is "us7ascii".and i save chinese charset in the database ,normally ,i get the data from the database ,use
    Statement s =conn.createStatement();
    then execute the sql, then use
    new String (string.getBytes("iso-8859-1"),"gbk")
    i can get the correct data.but if i use:
    Statement s = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    still use:
    new String (string.getBytes("iso-8859-1"),"gbk")
    convert the encode,but i can't get the correct data ,the result is "?????" ,why ?

    rp0428 wrote:
    Really? Please explain how that is possible.
    The US7ASCII only uses 7 bits to represent each character so can only represent 128 characters; none of them are chinese.Perhaps the sleazy hack "new String(string.getBytes())" actually works to encode and decode characters between Unicode and 7-bit ASCII -- but I haven't got the energy to figure out how it might work. My response to this sort of question is "Configure Oracle with the right character set in the first place so you don't have to deal with it at the application level".

  • ResultSet.absolute(int) Performance Issue

    I'm using the Oracle driver. I've run some tests and it appears that:
    ResultSet rs = ...;
    rs.absolute(n);
    has approximately the same performance as:
    ResultSet rs = ...;
    for (int i = 0; i < n; i++)
    rs.next();
    Is this all it is doing? For large values of "n" this could be very bad.
    I'd use "ROWNUM", but I also use an O/R framework. The only way to
    pull out specific subsets is to use JDBC scrolling. Is there anything I
    can do?
    Thanks,
    Bob

    Bob Lee wrote:
    There are at least 4 oracle driver vendors and
    multiple versions from each, so let us know
    which one you're using. See more below...I've tried the Oracle OCI (thick) and thin drivers, version 9.
    It certainly may be doing this. Very few drivers would go to the
    DBMS for each row individually, in a random access fashion.
    The driver would probably obtain and buffer all the intermediate
    rows that had not been fetched.This sucks. If I call ResultSet.absolute(), I probably don't need all of
    the intermediate rows.But you asked for them, so the driver and DBMS think you probably
    want them. Absolute() is part of implementing random access. It would
    never be interpreted as 'I don't want (some) rows'. It can be called to
    go backwards from the current position too.
    Clever SQL can be made to select the subsets (contiguous ranges) you want, one by oneDamn.It's a solution.... This sounds like something you want to do in a stored procedure.
    The cardinal performance problem in RDBMS applications is shipping scads of
    raw data out of the DBMS to the client, to be processed and/or discarded, instead
    of processing the raw stuff where it is in the DBMS.
    Good luck,
    Joe
    >
    Thanks,
    Bob
    Thanks,
    Bob

  • OIM 9.1 and ADSync Connecter from 9041 (Version: 4.5.0) issues

    Has anyone successfully configured these two together yet? I am in the process of trying to configure it properly and during the process of changing the User Defined field, it is giving a tcStaleDataUpdateException.
    Below is the full log of a password change cycle:
    05 Mar 2008 15:46:32 INFO Logger created
    05 Mar 2008 15:46:32 INFO Triggering Password Synchronization mechanism
    05 Mar 2008 15:46:34 INFO Value of the installedFlag=>true
    05 Mar 2008 15:46:34 INFO Password Reset Installed..get the ITResourceType and
    ITResourceName
    05 Mar 2008 15:46:34 INFO IT ResourceType Name=>AD Server
    05 Mar 2008 15:46:34 INFO ITResourceName=>OIM-WGC
    05 Mar 2008 15:46:34 INFO Logging to OIM server
    05 Mar 2008 15:46:34 INFO Logging into OIM Server with an auth mechanism
    05 Mar 2008 15:46:34 INFO Necassary Configurations read
    05 Mar 2008 15:46:34 INFO Logging into OIM Server with uname/pwd based auth
    05 Mar 2008 15:46:41 INFO Logging into OIM Server with uname/pwd based auth
    05 Mar 2008 15:46:41 INFO Initializing API instances
    05 Mar 2008 15:46:41 INFO Login completed
    05 Mar 2008 15:46:41 INFO Get the value of IT Resource parameter
    05 Mar 2008 15:46:43 INFO Set the value of IT Resource parameter to LDAP connec
    tion variables
    05 Mar 2008 15:46:43 INFO Check whether the ADsync is activated through ADServe
    r or OIM user
    05 Mar 2008 15:46:43 INFO Inside checkOIMFlag
    05 Mar 2008 15:46:43 INFO Going to connect AD
    05 Mar 2008 15:46:43 INFO Successful connected to AD
    05 Mar 2008 15:46:43 INFO Check the value of the customAtrributeName
    05 Mar 2008 15:46:43 INFO Enumerate the attributes
    05 Mar 2008 15:46:43 INFO objectGUID-->01afea406b229543b856de73305de058
    05 Mar 2008 15:46:43 INFO samName-->BW140435
    05 Mar 2008 15:46:43 INFO userPrincipalName-->BW140435
    05 Mar 2008 15:46:43 INFO User Defined field value-->0
    05 Mar 2008 15:46:43 INFO Custom Atrribute value is 0
    05 Mar 2008 15:46:43 INFO return from checkOIMFlag
    05 Mar 2008 15:46:43 INFO Password for this user needs to be updated through sy
    nchronization
    05 Mar 2008 15:46:43 INFO userId--->BW140435
    05 Mar 2008 15:46:43 INFO matchType--->UserID
    05 Mar 2008 15:46:43 INFO Inserted BW140435 in Input
    05 Mar 2008 15:46:43 INFO Find the user in OIM :
    05 Mar 2008 15:46:43 INFO After findUser :: userRS.size : 1
    05 Mar 2008 15:46:43 INFO User BW140435 = 71
    05 Mar 2008 15:46:43 INFO Set the value of UDF field to ADSYNC_TRUE value
    05 Mar 2008 15:46:43 INFO Going to update the USR_UDF_ADSYNC to ADSYNC_TRUE
    05 Mar 2008 15:46:45 INFO update the value of USR_UDF_ADSYNC to ADSYNC_TRUE
    05 Mar 2008 15:46:45 INFO Invoking OIM API for setting password
    05 Mar 2008 15:46:46 INFO Password changed
    05 Mar 2008 15:46:46 ERROR Unable to update status
    Thor.API.Exceptions.tcStaleDataUpdateException
    at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:290)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:248)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl_816_WLStub.updateUser(Unknown Source)
    at Thor.API.Operations.tcUserOperationsClient.updateUser(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at Thor.API.Base.SecurityInvocationHandler$1.run(Unknown Source)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.security.Security.runAs(Security.java:41)
    at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(Unknown Source)
    at Thor.API.Base.SecurityInvocationHandler.invoke(Unknown Source)
    at $Proxy0.updateUser(Unknown Source)
    at com.thortech.xl.integration.adpasswordsynch.ChangePassword.changePassword(Unknown Source)
    at com.thortech.xl.integration.adpasswordsynch.ChangePassword.main(Unknown Source)
    Caused by: Thor.API.Exceptions.tcStaleDataUpdateException
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUserData(Unknown Source)
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUser(Unknown Source)
    at com.thortech.xl.ejb.beans.tcUserOperationsSession.updateUser(UnknownSource)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl.updateUser(tcUserOperations_voj9p2_EOImpl.java:2302)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:120)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:429)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    05 Mar 2008 15:46:46 INFO Set the value of UDF field to ADSYNC_FALSE value
    05 Mar 2008 15:46:46 INFO Going to update the USR_UDF_ADSYNC to ADSYNCH_FALSE
    05 Mar 2008 15:46:46 ERROR Unable to update status
    Thor.API.Exceptions.tcStaleDataUpdateException
    at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:290)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:248)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl_816_WLStub.updateUser(Unknown Source)
    at Thor.API.Operations.tcUserOperationsClient.updateUser(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at Thor.API.Base.SecurityInvocationHandler$1.run(Unknown Source)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.security.Security.runAs(Security.java:41)
    at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(Unknown Source)
    at Thor.API.Base.SecurityInvocationHandler.invoke(Unknown Source)
    at $Proxy0.updateUser(Unknown Source)
    at com.thortech.xl.integration.adpasswordsynch.ChangePassword.changePassword(Unknown Source)
    at com.thortech.xl.integration.adpasswordsynch.ChangePassword.main(Unknown Source)
    Caused by: Thor.API.Exceptions.tcStaleDataUpdateException
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUserData(Unknown Source)
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUser(Unknown Source)
    at com.thortech.xl.ejb.beans.tcUserOperationsSession.updateUser(UnknownSource)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl.updateUser(tcUserOperations_voj9p2_EOImpl.java:2302)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:120)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:429)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    05 Mar 2008 15:46:46 INFO Password synch over
    05 Mar 2008 15:46:46 INFO Before System.exit(0):
    -Kevin

    For anyone else trying to setup AD Sync with 9.1, i was able to resolve the issue by decompiling the ChangePassword.class file and rewrite the changePassword method.
    The cause for the error was due to prior to the password change, the user defined field is changed, and after the password change, the same ResultSet is being used when the next value is being written to the field. Since the data had changed, the latest Exception handling would not allow the change due to the ResultSet being old/stale data.
    Also, you will run into a looping issue for bi-direction password resets because when you make a change in AD, the password in OIM is reset, which triggers the Change User Password task, which triggers the Password Updated if you are just returning the new password to the Password field, which tries to reset the password in AD again. This will lock up the domain controller. To get around this, you need to create custom code to check the value of the user defined field. If it's true, then run the setProcessData of the AD User form, otherwise, just stop.
    And finally, on the AD Set User Password adapter, you will need to set the adsync schema attribute to 1 prior to the password reset, to prevent the passing of the value onto OIM again. After the password change is complete, change the adsync attribute back to 0.
    -Kevin

  • 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.

  • Connection/ResultSets/Prepared Statement opening and closing

    Hi all another question that was sparked by a thread that I recently read. I believe it was duffmo who got the code from jverd. The code I am referring to is to have an open and close connection specified in a Utility or Database class. I wanted to know if there was any issues with having methods that open and close connections/result sets/ preparedStatements. Currently I am putting the finally blocks inside each of my methods. There is obvious benefits to putting the methods in a class on their own (namely code re-use) but I wanted to know if there are any dangers. (This may seem like a dumb question, but I've found from experience it's the things that you don't know that will cost you loads of time).
    thanks again.

    Hi all another question that was sparked by athread
    that I recently read. I believe it was duffmo who
    got the code from jverd. Generally speaking it's fine.
    But as always you may have some long term design
    issues to think about. If you build a simple
    framework that consists of one class and that does
    all that your program does then great.
    Once you start add more complexity though you'll want
    to be careful that you aren't reinventing the Spring
    wheel or even ending up implementing your own
    connection pool. Both of which, judging from posts
    here seem to happen from time to time.
    So I guess all in all, yes it's much better than
    scattering the code all about but depending on what
    you are going to be doing with it you may want to
    look at the various ORM frameworks to see if they are
    really the direction you should be going in.Thanks for the information cotton. I just wanted to make certain that it was a sensible thing to do. When I had first asked about connections I was told they should be opened an closed in the same spot, unfortunately I took that explanation a little too much to heart, and started opening and closing every connection resultset and prepared statement in each of the DAO classes that I was using.
    Guess it's going to be a bit of work to refactor, but worth it for the cleaner code that will result.

  • Some java code returns a null resultset from 10.2.0.1 DB, but works w/ 9.2

    I am a Java noob guys, but we have java code the calls an Oracle Function. This code is unchanged from what successfully runs against an Oracle 9.2 database returning, in this case, one row from the database. A ref cursor is used. When the same Java code calls the same ref cursor function from a 10.2.0.1 database, a null resultset occurs. The function correctly returns a single row when executed by the same database user via sql-plus. So it must be a java thing. Does the jdbc driver need to be upgraded to correctly run against a 10.2 database? And is this null resultset type of anomaly a potential result of having a wrong version of ojdbc14.jar? Nothing else has changed except pointing the code to the same package and tables in a 10.2 database.
    Thanks in advance for your comments.
    Phil McDermott

    I realize now that this is the wrong forum to post in, but I was linked here from a google search on the issue.
    I downloaded the 10.2.0.1 ojdbc14.jar from oracle, but the problem persists.
    yeesh! now what?

Maybe you are looking for