mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
testing for insertRow
This commit is contained in:
parent
164e1bc913
commit
422c2e38a1
@ -28,24 +28,26 @@ public class UpdateableResultTest extends TestCase
|
||||
Connection con = TestUtil.openDB();
|
||||
TestUtil.createTable(con, "updateable","id int primary key, name text, notselected text");
|
||||
TestUtil.createTable(con, "second","id1 int primary key, name1 text");
|
||||
Statement st1 = con.createStatement();
|
||||
boolean retVal = st1.execute( "insert into updateable ( id, name, notselected ) values (1, 'jake', 'avalue')" );
|
||||
assertTrue(!retVal);
|
||||
|
||||
retVal = st1.execute( "insert into second (id1, name1) values (1, 'jake')" );
|
||||
assertTrue( !retVal );
|
||||
st1.close();
|
||||
// put some dummy data into second
|
||||
Statement st2 = con.createStatement();
|
||||
st2.execute( "insert into second values (1,'anyvalue' )");
|
||||
st2.close();
|
||||
|
||||
Statement st = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
|
||||
ResultSet rs = st.executeQuery( "select id, name, notselected from updateable" );
|
||||
|
||||
ResultSet rs = st.executeQuery( "select * from updateable");
|
||||
assertNotNull( rs );
|
||||
rs.moveToInsertRow();
|
||||
rs.updateInt( 1, 1 );
|
||||
rs.updateString( 2, "jake" );
|
||||
rs.updateString( 3, "avalue" );
|
||||
rs.insertRow();
|
||||
rs.first();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
rs.updateInt( "id",2 );
|
||||
rs.updateString( "name","dave" );
|
||||
rs.updateRow();
|
||||
|
||||
assertTrue( rs.getInt("id") == 2 );
|
||||
assertTrue( rs.getString("name").equals("dave"));
|
||||
assertTrue( rs.getString("notselected").equals("avalue") );
|
||||
@ -61,7 +63,6 @@ public class UpdateableResultTest extends TestCase
|
||||
assertTrue( rs.getString("name").equals("paul"));
|
||||
assertTrue( rs.getString("notselected") == null );
|
||||
|
||||
}
|
||||
|
||||
rs.close();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user