I'm trying to insert into a column code from table calcul the last id of column code from table stock, this is my request which doesn't work.
String sql1="INSERT INTO calcul (idproduit,inventaire,consomation,date,quantite,designation,dateper,ppa,tr,net,code) "
+ "VALUES ('"+codeP+"',"+newQuant+","+0+",'"+datestock+"',"+newQuant+",'"+designation+"','"+datePer+"',"+PPA+","+TR+","+NET+",SELECT MAX(code) from stock );";
stmt.executeUpdate(sql1);
stocktable? Or independently? If you are doing this after adding a value to the stock table, are you using the same connection object for that and for this statement? Please add the relevant code.codevalue was generated with a sequence, use thelastval()function.