moveToInsertRow problem in Oracle. please help
From: hilz (nobody_at_nowhere.com)
Date: 12/09/03
- Next message: ThePotPlants: "Re: Which one is better,PostgreSQL or MySQL ?"
- Previous message: Thijs David: "Newbie : interbase , socket connection error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 8 Dec 2003 18:42:41 -0500
Hi Oracle/Java experts,
I am running into difficulties getting an updatable statement to work.
I have a table with an id column that has a trigger to create a new id
everytime a new row is inserted ( and ofcourse other columns).
I create a statement then i moveToInsertRow, and then insertRow. (see code
at the end).
The new row is created in the database and the id is generated by the
trigger, which is fine, but in the java program, the resultset does not
point to the newly inserted row. i need to retrieve the id from the new row,
but it is not working.
It seems after the insertRow() call, the resultset becomes empty and if i
call rs.getRow it gives 0 (which meanse there is no current row)
N.B. if i connect to MS ACCESS instead of oracle, the same code works fine.
after the insertRow call, the current row becomes the newly inserted row.
any help is appreciated. The code is below. thanks
hilz
Statement stmt = databaseConnection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT THE_TABLE.* from
THE_TABLE");
rs.moveToInsertRow();
rs.insertRow();//works fine and inserts a row in the table, with a
new id that is generated by the trigger
//I tried to call rs.moveToCurrentRow() here but it did not help.
int row = rs.getRow();//returns 0 which means there is no current
row.(or the result set is empty).WHY!?
- Next message: ThePotPlants: "Re: Which one is better,PostgreSQL or MySQL ?"
- Previous message: Thijs David: "Newbie : interbase , socket connection error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]