Re: updateable cursors & visibility - Mailing list pgsql-hackers

From snpe
Subject Re: updateable cursors & visibility
Date
Msg-id 200303251415.22695.snpe@snpe.co.yu
Whole thread Raw
In response to updateable cursors & visibility  (Neil Conway <neilc@samurai.com>)
List pgsql-hackers
Hello Neil, I try example for Oracle jdbc 1.4 driver This is sample and results. I hope that is helps.
 If you want yet another example, please tell me.

regards
Haris Peco

/*** A simple sample to check the availability of scrollable result sets.** Please use jdk1.2 or later version*/

import java.sql.*;

public class ResultSetmy1
{ public static void main(String[] args) throws SQLException {   // Load the Oracle JDBC driver
DriverManager.registerDriver(neworacle.jdbc.OracleDriver());
 
   String url = "jdbc:oracle:thin:@spnew:1521:V9i";   try {     String url1 = System.getProperty("JDBC_URL");     if
(url1!= null)       url = url1;   } catch (Exception e) {     // If there is any security exception, ignore it     //
anduse the default   }
 
   // Connect to the database   // You can put a database name after the @ sign in the connection URL.   Connection
conn=     DriverManager.getConnection (url, "scott", "tiger");
 
   // Get the metadata regarding this connection's database   DatabaseMetaData dbmd = conn.getMetaData();
   // List all the possible result set types   int resultset_types[] =    {     ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE,    ResultSet.TYPE_SCROLL_SENSITIVE    };
 
   // List all the possible result set concurrency types   int concurrency_types[] =    {
ResultSet.CONCUR_READ_ONLY,    ResultSet.CONCUR_UPDATABLE    };
 
   // List the result set type names   String resultset_types_msg [] =    {     "Forward only",      "Scroll
insensitive",     "Scroll sensitive"   };
 
   // List the concurrency type names   String concurrency_types_msg[] =    {      "Read only",      "Updatable"    };
   // Check the availability of the result type and concurrency type   for (int i=0; i<resultset_types.length; i++)   {
   for (int j=0; j<concurrency_types.length; j++)     {       int type = resultset_types[i];       int concurrency =
concurrency_types[j];
       System.out.println ("Type: "+resultset_types_msg[i]+"    "+                           "Concurrency:
"+concurrency_types_msg[j]);      System.out.println
("----------------------------------------------------");
       // Return true if the result set type is supported       System.out.println ("supportResultSetType: "+
               dbmd.supportsResultSetType(type));
 
       // Return true if the result set type and concurrency type is supported       System.out.println
("supportsResultSetConcurrency:"+                       dbmd.supportsResultSetConcurrency(type, concurrency));
 
       // Return true if the result set's updates are visible       System.out.println ("ownUpdatesAreVisible: "+
                   dbmd.ownUpdatesAreVisible(type));
 
       // Return true if the result set's deletions are visible       System.out.println ("ownDeletesAreVisible: "+
                     dbmd.ownDeletesAreVisible(type));
 
       // Return true if the result set's insertions are visible       System.out.println ("ownInsertAreVisible: "+
                     dbmd.ownInsertsAreVisible(type));
 
       // Return true if other's changes are visible       System.out.println ("othersUpdatesAreVisible: "+
             dbmd.othersUpdatesAreVisible(type));
 
       // Return true if other's deletions are visible       System.out.println ("othersDeletesAreVisible: "+
               dbmd.othersDeletesAreVisible(type));
 
       // Return true if other's insertions are visible       System.out.println ("othersInsertsAreVisible: "+
                dbmd.othersInsertsAreVisible(type));
 
       // Return true if ResultSet.rowUpdated() is supported       System.out.println ("updatesAreDetected: "+
                dbmd.updatesAreDetected(type));
 
       // Return true if ResultSet.rowDeleted() is supported       System.out.println ("deletesAreDetected: "+
                dbmd.deletesAreDetected(type));
 
       // Return true if ResultSet.rowInserted() is supported       System.out.println ("insertsAreDetected: "+
                 dbmd.insertsAreDetected(type));
 
       System.out.println ();     }   }
   // Close the connection   conn.close();    }
}

This is results :

Type: Forward only    Concurrency: Read only
----------------------------------------------------
supportResultSetType: true
supportsResultSetConcurrency: true
ownUpdatesAreVisible: false
ownDeletesAreVisible: false
ownInsertAreVisible: false
othersUpdatesAreVisible: false
othersDeletesAreVisible: false
othersInsertsAreVisible: false
updatesAreDetected: false
deletesAreDetected: false
insertsAreDetected: false

Type: Forward only    Concurrency: Updatable
----------------------------------------------------
supportResultSetType: true
supportsResultSetConcurrency: true
ownUpdatesAreVisible: false
ownDeletesAreVisible: false
ownInsertAreVisible: false
othersUpdatesAreVisible: false
othersDeletesAreVisible: false
othersInsertsAreVisible: false
updatesAreDetected: false
deletesAreDetected: false
insertsAreDetected: false

Type: Scroll insensitive    Concurrency: Read only
----------------------------------------------------
supportResultSetType: true
supportsResultSetConcurrency: true
ownUpdatesAreVisible: true
ownDeletesAreVisible: true
ownInsertAreVisible: false
othersUpdatesAreVisible: false
othersDeletesAreVisible: false
othersInsertsAreVisible: false
updatesAreDetected: false
deletesAreDetected: false
insertsAreDetected: false

Type: Scroll insensitive    Concurrency: Updatable
----------------------------------------------------
supportResultSetType: true
supportsResultSetConcurrency: true
ownUpdatesAreVisible: true
ownDeletesAreVisible: true
ownInsertAreVisible: false
othersUpdatesAreVisible: false
othersDeletesAreVisible: false
othersInsertsAreVisible: false
updatesAreDetected: false
deletesAreDetected: false
insertsAreDetected: false

Type: Scroll sensitive    Concurrency: Read only
----------------------------------------------------
supportResultSetType: true
supportsResultSetConcurrency: true
ownUpdatesAreVisible: true
ownDeletesAreVisible: true
ownInsertAreVisible: false
othersUpdatesAreVisible: true
othersDeletesAreVisible: false
othersInsertsAreVisible: false
updatesAreDetected: false
deletesAreDetected: false
insertsAreDetected: false

Type: Scroll sensitive    Concurrency: Updatable
----------------------------------------------------
supportResultSetType: true
supportsResultSetConcurrency: true
ownUpdatesAreVisible: true
ownDeletesAreVisible: true
ownInsertAreVisible: false
othersUpdatesAreVisible: true
othersDeletesAreVisible: false
othersInsertsAreVisible: false
updatesAreDetected: false
deletesAreDetected: false
insertsAreDetected: false


On Monday 24 March 2003 09:49 pm, Neil Conway wrote:
> Folks,
>
> I'd like to implement updateable cursors. I'll be working on just
> getting updateable cursors working for relatively simple SELECT queries
> (e.g. no joins, aggregates, grouping, user-defined function calls,
> etc.). BTW, I believe that's all the SQL spec requires, but I need to
> double check that. I'm also planning on only implementing only
> INSENSITIVE cursors, and not allowing holdable cursors.
>
> However, I'm a little unsure how tuple visibility should work with
> updateable cursors. In particular:
>
> - if the user updates a row X in the cursor, then rewinds the cursor and
> fetches X again, should they see the new X or the old X?
>
> - if the user updates a row X in the cursor, and then a query within the
> cursor's transaction views X, should the query see new X or old X?
>
> Any comments?
>
> Neil
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster



pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: plpgsql compile failure
Next
From: Tom Lane
Date:
Subject: Re: plpgsql compile failure