Possible Duplicate:
PLSQL JDBC: How to get last row ID?
I have problem getting ID from tables. I have two tables AJPES_TR and TR_LOG and PK from TR_LOG table is set as foreign key in AJPES_TR table.
In TR_LOG table I just write from which file data was imported and I want to link that PK into main table. In mySQL I was doing just fine with getID.last(); int j = getID.getInt(TR_LOG_ID);
but now in Oracle this doesn't work anymore.
These are my PreparedStatements:
PreparedStatement insertData =
con.prepareStatement(
"INSERT INTO T_AJPES_TR(rn,sSpre,reg,eno,davcna,Ime,Priimek) VALUES (?,?,?,?,?,?,?)"
);
PreparedStatement select_file_log =
con.prepareStatement("SELECT * FROM T_AJPES_TR_LOG WHERE File_import = ?"
);
PreparedStatement getID = con.prepareStatement("SELECT * FROM T_AJPES_TR_LOG");
PreparedStatement insertFile =
con.prepareStatement(
"INSERT INTO T_AJPES_TR_LOG(Date_import,File_import) VALUES (?,?)"
);
In mySQL IDs were set as autoincrement.
How can I get ID value from TR_LOG and write that value in AJPES_TR table?