Probem with updateable resultset

i have large view in database , i want to update virtual columns in this view , i used resultset to update this virtual columns , but there are exception that resultset is readonly .
my question i want to update these virtual columns with resultset or cashrowset .
i want these to make some calculation in run time before run report .
Statement stmt = connection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet resultSet = stmt.executeQuery("SELECT * FROM employeedata_view");
resultSet.first();
resultSet.updateString("col_string", "join");
resultSet.updateRow();

Does your database support update-able views? If not, there's no way it's going to work from Java.

Similar Messages

  • Problem with Updateable ResultSet

    Hi,
    I'm having a problem updating an updateable resultset. When I query the database using anything other than the LIKE clause, I can update the resultset just fine. As soon as I add the LIKE clause to my select query and then try to update one of the records in the resultset I get an "Error in row". The database I am using is MS Access (yes I know, not a good choice), and I am using the driver that comes built into Java. I am also running JDK 1.5_06.
    I've looked to see if maybe this is a known bug, but haven't found anything related to this. Has anyone else seen this same problem? Or know of a way to get around it?
    Thank you in advance.

    I'm confused then... Why would I be able to update
    the resultset when I select that resultset not using
    the LIKE clause, but when I use the LIKE clause to
    get the resultset and then try to update it in some
    way, I get an error. Because the database isn't giving you an updatable cursor if you use a like apparently. It just isn't. Don't know why.
    Obviously the resultset is
    updateable, Obviously not.
    and I have selected the right cursor type
    for each parameter (TYPE_SCROLL_INSENSITIVE and
    CONCUR_UPDATABALE). I am sure you are but what you ask for is not always what you get.
    I understand that it is not
    required for the database and/or driver to fulfill my
    wishes, but it seems odd Yes it does seem a bit odd but that doesn't make it less true. To be frank with you I can't remember the last time I used an updatable result set.
    It's one of these things that seem all nifty at first but it's all very quirky and resource intensive and in almost all cases was better handled by an INSERT, UPDATE or DELETE statement in the first place.
    that it I am able to update
    the resultset when I have not used the LIKE clause to
    create it, but am unable to update it when having
    created it using the LIKE clause. :shrug: Because. I couldn't tell you why it does it this way. I am sure it has something to do with how it builds the cursor... generally in MS database stuff there are dynamic and static (or fixed I can't remember the names) "keysets" for a given result set. I am mangling the terminolgy here but it doesn't really matter... the point is with MS databases the way you search combined with any clauses combined with what fields you select all effect the ending cursor types you can have. This is true for most databases really... and to make a long story short I guess that a LIKE is just making the backing keyset or whatever non updatable.
    I'll try your tip
    of listing all of the columns instead of using * to
    see if that makes a difference.It might but don't get your hopes up.
    This is a general tip you can use to try and get an updatable cursor but honestly in your case I am not sure it will help. It seems to me that you are going to have to not use LIKE.
    Which means you can either give up the updatable cursor OR the like. If you have to have an updatable cursor AND the LIKE then you are going to have to do this in two steps.
    Query 1 - Select the keys by LIKE
    Query 2 - Select updatable cursor using the keys from query 1
    But that seems terribly painful.

  • IBM DB2 with Updateable ResultSets

    I'm working on a cross database application that uses updateable resultsets.
    I've run it on mysql and postgres.
    And using JTDS and DataDirect I've got SQL Server functionality working.
    But now I'm trying to deploy it on DB2 using the UDB dirver. But it seems that it doesn't support Updatable ResultSets.
    The driver I'm using came with the DB2 Personal Edition.
    Is there another driver by IBM that supports updatable resultsets, or will I be forced inyo finding a thrid party driver for my work?

    I believe I was using the type 4 one, but I got a SQL Exception simply saying "Driver not Capable" when I ran it.
    The DataDirect one should work, but it is also responsible for connection hijacking.
    What that is that once you register the DB2 Driver, and you use DriverManager to get a connection, it assumes that ALL calls to DriverManager.getConnection() are for DB2 connections, even though I use Postgres connections as well. When I try to get a postgres connection, the DB2 driver throws an exception saying that it can't connect to the datasource!

  • Scrollable/Updateable ResultSet objects

    I am trying to create an instance of a scrollable/updateable ResultSet object with the following code:
    Statement stmt = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery("SELECT * FROM sch.a");
    The Connection object has been made successfully but am getting an AbstractMethodError Exception at line 1.
    Can anyone please help me out here.
    Thanks
    I am using JDK 1.3.1 and JDBC 2.0

    I use this and works fine for me....let me know how it goes...
    ResultSet resultSetMultCond = null;
    Statement getMultPartCond = null;
    String sqlMultCond = null;
    sqlMultCond = "SELECT #PART,#CONDS,COUNT(*) AS MCOUNT FROM MYLIB WHERE #PART = 'A123' GROUP BY #PART,#CONDS ORDER BY #PART";
    getMultPartCond = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
    resultSetMultCond = getMultPartCond.executeQuery(sqlMultCond);

  • No updateable ResultSet

    Hi,
    I'm trying to do an update with the ResultSet, but I always get an exception
    that I can't do an update on a read-only ResultSet. I set the
    ResultSet.CONCUR_UPDATABLE but it is not working.
    Here is the code:
    //-------------------------------------------PreparedStatement stmt = conn.prepareStatement(SELECT_CD,
    ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    // debug message
    cat.debug("Statement: " + stmt.getResultSetConcurrency());
    // do some filling of the prepared statement
    ResultSet rs = stmt.executeQuery();
    // debug messages
    cat.debug("CONCUR_UPDATABLE: " + rs.CONCUR_UPDATABLE);
    cat.debug("CONCUR_READ_ONLY: " + rs.CONCUR_READ_ONLY);
    cat.debug("ResultSet: " + rs.getConcurrency());
    // update
    if(rs.next())
    // we have an entry
    rs.updateString(4, srcSystemInstance());
    rs.updateString(5, srcSystemType());
    rs.updateRow();
    The output of the debug messages:
    Statement: 1008
    CONCUR_UPDATABLE: 1008
    CONCUR_READ_ONLY: 1007
    ResultSet: 1007
    Even the statement is updateable, the ResultSet is still read-only.
    I'm using JDK1.3 under Window2000 and connecting to an Oracle 8.1.6 database
    with the OCI driver. (Oracle driver version 8.1.7.0.0).
    Any ideas what is wrong?
    Best Regards
    Juergen
    null

    When I tried it I did something like where dbConn is a working connection to Oracle (I can fetch data just fine). I tried a regular SELECT *, SELECT * with a WHERE clause, and using FOR UPDATE. All combinations fail
    and the dbConn is not read only, the statement is CONCUR_UPDATABLE, but the resultset is always read only.
    stmtw=
    dbConn.createStatement(
    ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    System.out.println("STMTW Concurrency is "+stmtw.getResultSetConcurrency()+" and should be "+ResultSet.CONCUR_UPDATABLE +" and not "+ResultSet.CONCUR_READ_ONLY);
    rsw=
    stmtw.executeQuery(
    "SELECT * FROM WTHR FOR UPDATE");
    System.out.println("DB READONLY :"+dbConn.isReadOnly());
    System.out.println("RSW Concurrency is "+rsw.getConcurrency()+" and should be "+ResultSet.CONCUR_UPDATABLE +" and not "+ResultSet.CONCUR_READ_ONLY);
    null

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

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

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

  • JTable and ResultSet TableModel with big resultset

    Hi, I have a question about JTable and a ResultSet TableModel.
    I have to develop a swing JTable application that gets the data from a ResultSetTableModel where the user can update the jtable data.
    The problem is the following:
    the JTable have to contain the whole data of the source database table. Currently I have defined a
    a TYPE_SCROLL_SENSITIVE & CONCUR_UPDATABLE statement.
    The problem is that when I execute the query the whole ResultSet is "downloaded" on the client side application (my jtable) and I could receive (with big resultsets) an "out of memory error"...
    I have investigate about the possibility of load (in the client side) only a small subset of the resultset but with no luck. In the maling lists I see that the only way to load the resultset incrementally is to define a forward only resultset with autocommit off, and using setFetchSize(...). But this solution doesn't solve my problem because if the user scrolls the entire table, the whole resultset will be downloaded...
    In my opinion, there is only one solution:
    - create a small JTable "cache structure" and update the structure with "remote calls" to the server ...
    in other words I have to define on the server side a "servlet environment" that queries the database, creates the resultset and gives to the jtable only the data subsets that it needs... (alternatively I could define an RMI client/server distribuited applications...)
    This is my solution, somebody can help me?
    Are there others solutions for my problem?
    Thanks in advance,
    Stefano

    The database table currently is about 80000 rows but the next year will be 200000 and so on ...
    I know that excel has this limit but my JTable have to display more data than a simple excel work sheet.
    I explain in more detail my solution:
    whith a distribuited TableModel the whole tablemodel data are on the server side and not on the client (jtable).
    The local JTable TableModel gets the values from a local (limited, 1000rows for example) structure, and when the user scroll up and down the jtable the TableModel updates this structure...
    For example: initially the local JTable structure contains the rows from 0 to 1000;
    the user scroll down, when the cell 800 (for example) have to be displayed the method:
    getValueAt(800,...)
    is called.
    This method will update the table structure. Now, for example, the table structure will contain data for example from row 500 to row 1500 (the data from 0 to 499 are deleted)
    In this way the local table model dimension will be indipendent from the real database table dimension ...
    I hope that my solution is more clear now...
    under these conditions the only solutions that can work have to implement a local tablemodel with limited dimension...
    Another solution without servlet and rmi that I have found is the following:
    update the local limited tablemodel structure quering the database server with select .... limit ... offset
    but, the select ... limit ... offset is very dangerous when the offset is high because the database server have to do a sequential scan of all previuous records ...
    with servlet (or RMI) solution instead, the entire resultset is on the server and I have only to request the data from the current resultset from row N to row N+1000 without no queries...
    Thanks

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

  • BUG JSF h:dataTable with JDBC ResultSet - only last column is updated

    I tried to create updatable h:dataTable tag with three h:inputText columns with JDBC ResultSet as data source. But what ever I did I have seceded to update only the last column in h:dataTable tag.
    My JSF page is:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1250"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <f:view>
    <html>
    <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1250"/>
    <title>Stevan</title>
    </head>
    <body><h:form>
    <p>
    <h:messages/>
    </p>
    <p>
    <h:dataTable value="#{tabela.people}" var = "record">
    <h:column>
    <f:facet name="header">
    <h:outputText value="PIN"/>
    </f:facet>
    <h:inputText value="#{record.PIN}"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Surname"/>
    </f:facet>
    <h:inputText value="#{record.SURNAME}"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Name"/>
    </f:facet>
    <h:inputText value="#{record.NAME}"/>
    </h:column>
    </h:dataTable>
    </p>
    <h:commandButton value="Submit"/>
    </h:form></body>
    </html>
    </f:view>
    My java been is:
    package com.steva;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class tabela {
    private Connection conn;
    private ResultSet resultSet;
    public tabela() throws SQLException, ClassNotFoundException {
    Statement stmt;
    Class.forName("oracle.jdbc.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    resultSet = stmt.executeQuery("SELECT PIN, SURNAME, NAME FROM PERSON");
    public ResultSet getPeople() {
    return resultSet;
    I have instaled “Oracle Database 10g Express Edition Release 10.2.0.1.0” – product on my PC localy. I have enabled HR schema and I have instaled and pupulated with sample data folloving table:
    CREATE TABLE "PERSON"
    (     "PIN" VARCHAR2(20) NOT NULL ENABLE,
         "SURNAME" VARCHAR2(30),
         "NAME" VARCHAR2(30),
         CONSTRAINT "PERSON_PK" PRIMARY KEY ("PIN") ENABLE
    I have:
    Windows XP SP2
    Oracle JDeveloper Studio Edition Version 10.1.3.1.0.3894
    I am not shure why this works in that way, but I think that this is a BUG
    Thanks in advance.

    Hi,
    I am sorry because of formatting but while I am entering text looks fine but in preview it is all scrambled. I was looking on the Web for similar problems and I did not find anything similar. Its very simple sample and I could not believe that the problem is in SUN JSF library. I was thinking that problem is in some ResultSet parameter or in some specific Oracle implementation of JDBC thin driver. I did not try this sample on any other platform, database or programming tool. I am new in Java and JSF and I have some experience only with JDeveloper.
    Java been(session scope):
    package com.steva;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class tabela {
    private Connection conn;
    private ResultSet resultSet;
    public tabela() throws SQLException, ClassNotFoundException {
    Statement stmt;
    Class.forName("oracle.jdbc.OracleDriver");
    conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");
    stmt = conn.createStatement
    (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    resultSet = stmt.executeQuery("SELECT PIN, SURNAME, NAME FROM PERSON");
    public ResultSet getZaposleni() {
    return resultSet;
    JSF Page:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1250"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <f:view>
    <html>
    <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1250"/>
    <title>Stevan</title>
    </head>
    <body><h:form>
    <p>
    <h:messages/>
    </p>
    <p>
    <h:dataTable value="#{tabela.zaposleni}" var = "record">
    <h:column>
    <f:facet name="header">
    <h:outputText value="PIN"/>
    </f:facet>
    <h:inputText value="#{record.PIN}"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Surname"/>
    </f:facet>
    <h:inputText value="#{record.SURNAME}"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Name"/>
    </f:facet>
    <h:inputText value="#{record.NAME}"/>
    </h:column>
    </h:dataTable>
    </p>
    <h:commandButton value="Submit"/>
    </h:form></body>
    </html>
    </f:view>

  • SQL Server 2012 Transactional Replication with updateable subscriptioins

    Hi All,
    It is heard that Transactional Replication with Updateable Subscriptions
    is
    deprecated in SQL 2012 so it is not possible to configure through the wizards but
    we can still configure it by using T-SQL Script. Would you please share that script if possible to configure the same in SQL Server 2012. Thank You.
    Regards,
    Kalyan
    ----Learners Curiosity Never Ends----

    Thanks for the information,
    I understand that you have got the answer yourself and post it, Therefor I mark your answer. If this is still open question please inform us.
    [Personal Site] [Blog] [Facebook]

  • Trouble Populating CachedRowSetImpl with a ResultSet Containing a CLOB

    Hi,
    I need to populate a CachedRowSetImpl with a ResultSet that contains a CLOB. I am using the Oracle thin jdbc driver (ojdbc14.jar) When I populate it however, I get an exception:
    java.sql.SQLException: Invalid precision value. Cannot be less than zero
    Here is my code snippet. I get the exception when I call dor_note_dataRowSet.populate(resultSet);
    javax.naming.Context ctx = null;
    DataSource ds = null;
    Connection conn = null;
    PreparedStatement ps1 = null;
    String sqlUpdate = null;
    ResultSet resultSet = null;
    try
    ctx = new javax.naming.InitialContext();
    ds = (DataSource)ctx.lookup("<private>");
    conn = ds.getConnection();
    sqlQuery = "SELECT " +
    "DOR_NOTE_DT, DOR_NOTE_TX " +
    "FROM DOR.DOR_NOTE_DATA " +
    "WHERE DOR_NOTE_CD='SECURITY' AND " +
    "TO_CHAR(DOR_Note_Dt, 'mm/dd/yyyy') = '" + strDate + "'";
    ps1 = conn.prepareStatement(sqlQuery);
    resultSet = ps1.executeQuery();
    dor_note_dataRowSet.populate(resultSet);
    ps1.close();
    conn.close();
    catch (Exception ex) {
    log("Error Description", ex);
    error("Failed to upload file :"+ex.getMessage());
    Thanks

    I figured out how to do it

  • I want to bound my TextField with my ResultSet/DataControl

    Hi All,
    I want to bound my TextField and other GUI components with my ResultSet because i don't want to set the value on each navigation of ResultSet.
    Thanks

    Huh?
    What do you mean 'bound' it? Do you mean that somehow you want to connect a specific gui control to a specific bind parameter in a PreparedStatement?
    If so you aren't going to do that with standard java.
    You might be able to find a product that does that, or you could write it yourself. All it would do though is hide the functionality you are already using.

  • HT1657 i received an email about a probem with a movie rental

    i received an email about a probem with a movie rental and was given 1 rental credit. but i have no idea how to redeem that credit. i can see that i have it in my account info and at the the top right of the screen next to my account name but cant do anything with it. thanks

    You can't, directly on your phone. This is not supported on the iPhone. You need to get the song into your iTunes library, then sync it to your phone.

  • How to create updateable resultset using sql with "order by"

    Dear all,
    I'm using the Derby database to hold a table of stock prices. After the table is populated, I want to do some calculations and store the result in a column.
    I get the resultset using the following code
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(select history_id, value, days from history where ticker = '" + ticker + "' order by value_date"); {code} When I then try to update the "days" field, I get an SQLException telling me that the resultset is not updatable. However, if I remove the "order by" clause, I am able to update the data, but then my algorithm does not work as I need to traverse the data in a specific order. The quesion is: how do I create an updatable resultset using a sql-statement with an order by clause? Kind regards Karl Martin Lund                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    jschell wrote:
    Seems rather obvious to me that the exception specifically tells you that you can't do that.OP: I would guess it's because ORDER BY forces the database to read all the result rows into a temporary area, sort them, and then return them from this temporary area, as opposed to streaming the results. The extra step probably makes updateable result sets more difficult (or maybe not possible), so they opted not to do it.

  • Problem with store ResultSet and show result in table

    Hi, I'm kind of new in ADF, I need to store ResultSet and show result in table-component. I have two problems:
    1) I get my ResultSet by calling callStoredProcedure(...) and this returns actually ref_cursor as ResultSet.
    When I try to println() contains of this result set in this method - it works OK (commented part),
    but when I want to println() somewhere else (eg. in retrieveRefCursor() method) it doesn't work.
    The problem is that the scrollability of the ResultSet is lost - it becomes a TYPE_FORWARD_ONLY ResultSet.
    Is there any way to store data from ref_cursor for a long time?
    2) My second problem is "store any result set and show this data in table". I have tried use method storeNewResultSet() but
    without result (table contains only "No rows yet" and everything seems to be OK - no exception, no warning, no error...).
    I have tried to call this method with ResultSet from select on dbs (without resultSet as ref_cursor ) - no result with createRowFromResultSet(),
    storeNewResultSet(), setUserDataForCollection()...
    I've tried a lot of ways to do this, but it doesn't work. I really don't know how to make it so it can work.
    Thanks for your help.
    ADF BC, JDev 11.1.1.0
    This is my code from ViewObjectImpl
    package tp.model ;
    import com.sun.jmx.mbeanserver.MetaData ;
    import java.sql.CallableStatement ;
    import java.sql.Connection ;
    import java.sql.PreparedStatement ;
    import java.sql.ResultSet ;
    import java.sql.ResultSetMetaData ;
    import java.sql.SQLException ;
    import java.sql.Statement ;
    import java.sql.Types ;
    import oracle.jbo.JboException ;
    import oracle.jbo.server.SQLBuilder ;
    import oracle.jbo.server.ViewObjectImpl ;
    import oracle.jbo.server.ViewRowImpl ;
    import oracle.jbo.server.ViewRowSetImpl ;
    import oracle.jdbc.OracleCallableStatement ;
    import oracle.jdbc.OracleConnection ;
    import oracle.jdbc.OracleTypes ;
    public class Profiles1ViewImpl extends ViewObjectImpl {
        private static final String SQL_STM = "begin Pkg_profile.get_profile_list(?,?,?,?);end;" ;
        public Profiles1ViewImpl () {
        /* 0. */
        protected void create () {
            getViewDef ().setQuery ( null ) ;
            getViewDef ().setSelectClause ( null ) ;
            setQuery ( null ) ;
        public Connection getCurrentConnection () throws SQLException {
            // Note that we never execute this statement, so no commit really happens
            Connection conn = null ;
            PreparedStatement st = getDBTransaction ().createPreparedStatement ( "commit" , 1 ) ;
            conn = st.getConnection () ;
            st.close () ;
            return conn ;
        /* 1. */
        protected void executeQueryForCollection ( Object qc , Object[] params , int numUserParams ) {
            storeNewResultSet ( qc , retrieveRefCursor ( qc , params ) ) ;
            // callStoredProcedure ( qc , SQL_STM ) ;
            super.executeQueryForCollection ( qc , params , numUserParams ) ;
        /* 2. */
        private ResultSet retrieveRefCursor ( Object qc , Object[] params ) {
            ResultSet rs = null ;
            rs = callStoredProcedure ( qc , SQL_STM ) ;
            return rs ;
        /* 3. */
        public ResultSet callStoredProcedure ( Object qc , String stmt ) {
            CallableStatement st = null ;
            ResultSet refCurResultSet = null ;
            try {
                st = getDBTransaction ().createCallableStatement ( stmt , 0 ) ; // call 
                st.setObject ( 1 , 571 ) ; //set id of my record to 571
                st.registerOutParameter ( 2 , OracleTypes.CURSOR ) ; // my ref_cursor
                st.registerOutParameter ( 3 , Types.NUMERIC ) ;
                st.registerOutParameter ( 4 , Types.VARCHAR ) ;
                st.execute () ; //executeUpdate
                System.out.println ( "Numeric " + st.getObject ( 3 ) ) ;
                System.out.println ( "Varchar " + st.getObject ( 4 ) ) ;
                refCurResultSet = ( ResultSet ) st.getObject ( 2 ) ; //set Cursoru to ResultSet
                //   setUserDataForCollection(qc, refCurResultSet); //don't work
                //   createRowFromResultSet ( qc , refCurResultSet ) ; //don't work
                /* this works but only one-time call - so my resultSet(cursor) really have a data
                while ( refCurResultSet.next () ) {
                    String nameProfile = refCurResultSet.getString ( 2 ) ;
                    System.out.println ( "Name profile: " + nameProfile ) ;
                return refCurResultSet ;
            } catch ( SQLException e ) {
                System.out.println ( "sql ex " + e ) ;
                throw new JboException ( e ) ;
            } finally {
                if ( st != null ) {
                    try {
                        st.close () ; // 7. Close the statement
                    } catch ( SQLException e ) {
                        System.out.println ( "sql exx2 " + e ) ;
        /* 4. Store a new result set in the query-collection-private user-data context */
        private void storeNewResultSet ( Object qc , ResultSet rs ) {
            ResultSet existingRs = getResultSet ( qc ) ;
            // If this query collection is getting reused, close out any previous rowset
            if ( existingRs != null ) {
                try {
                   existingRs.close () ;
                } catch ( SQLException s ) {
                    System.out.println ( "sql err " + s ) ;
            setUserDataForCollection ( qc , rs ) ; //should store my result set
            hasNextForCollection ( qc ) ; // Prime the pump with the first row.
        /*  5. Retrieve the result set wrapper from the query-collection user-data      */
        private ResultSet getResultSet ( Object qc ) {
            return ( ResultSet ) getUserDataForCollection ( qc ) ;
        // createRowFromResultSet - overridden for custom java data source support - also doesn't work
       protected ViewRowImpl createRowFromResultSet ( Object qc , ResultSet resultSet ) {
            ViewRowImpl value = super.createRowFromResultSet ( qc , resultSet ) ;
            return value ;
    }

    Hi I have the same problem like you ...
    My SQL Definition:
    CREATE OR REPLACE TYPE RMSPRD.NB_TAB_STOREDATA is table of NB_STOREDATA_REC
    CREATE OR REPLACE TYPE RMSPRD.NB_STOREDATA_REC AS OBJECT (
       v_title            VARCHAR2(100),
       v_store            VARCHAR2(50),
       v_sales            NUMBER(20,4),
       v_cost             NUMBER(20,4),
       v_units            NUMBER(12,4),
       v_margin           NUMBER(6,2),
       v_ly_sales         NUMBER(20,4),
       v_ly_cost          NUMBER(20,4),
       v_ly_units         NUMBER(12,4),
       v_ly_margin        NUMBER(6,2),
       v_sales_variance   NUMBER(6,2)
    CREATE OR REPLACE PACKAGE RMSPRD.NB_SALES_DATA
    AS
    v_sales_format_tab   nb_tab_storedata;
    FUNCTION sales_data_by_format_gen (
          key_value         IN       VARCHAR2,
          l_to_date         IN       DATE DEFAULT SYSDATE-1,
          l_from_date       IN       DATE DEFAULT TRUNC (SYSDATE, 'YYYY')
          RETURN nb_tab_storedata;
    I have a PLSQL function .. that will return table ..
    when i use this in sql developer it is working fine....
    select * from table (NB_SALES_DATA.sales_data_by_format_gen('TSC',
                                        '05-Aug-2012',
                                        '01-Aug-2012') )
    it returning table format record.
    I am not able to call from VO object. ...
    Hope you can help me .. please tell me step by step process...
    protected Object callStoredFunction(int sqlReturnType, String stmt,
    Object[] bindVars) {
    System.out.println("--> 1");
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement("begin ? := " +"NB_SALES_DATA.sales_data_by_format_gen('TSC','05-Aug-2012','01-Aug-2012') ; end;", 0);
    System.out.println("--> 2");
    st.executeUpdate();
    System.out.println("--> 3");
    return st.getObject(1);
    catch (SQLException e) {
    e.printStackTrace();
    throw new JboException(e);

Maybe you are looking for

  • Blue screen on Windows XP installation loading

    Hi... I am trying to install windows xp professional... I'm booting from cd and when the windows start to loads the installation tool a blue screen show and i have to restart....i tried with another cds and didn't work is that a block to doesn't inst

  • I recently got an iPhone 5 and I need some help...

    Ive noticed on my siblings iPods, that it has the option of having my phone number as a way to send messages to their devices. Since those are not my devices, how can I have it that my number wont show up on their devices? My problem is, in their set

  • Loading a CSV file and accessing the variables

    Hi guys, I'm new to AS3 and dealt with AS2 before (just getting the grasp when the change it). Is it possible in AS3 to load an excel .csv file into Flash using the URLLoader (or ???) and the data as variables? I can get the .csv to load and trace th

  • NVIDIA nForce4 system driver

    When installing the system drivers from mainbord cd, is it best not to install the NVIDIA IDE SW component as I am told it will cause problems.In fact what components should be installed and which left out? Is it possible to leave any out?  Ihave MSI

  • How to add hashes to sql querys

    The data I wish to add to mysql contains characters such as " and ' and so i get and exception when updating the database. How do I add hashes to the string so that I won't get the error: ie really "cool" becomes really /"cool/" though hashes should