Fórum PostgreSQL - INSERT RETURNING ID [RESOLVIDO] #569757
09/04/2009
0
1 2 3 | String qry = " INSERT INTO tb_pessoa(nome,ddd,fone, etc...) VALUES (?,?,?, etc...) RETURNING id_paciente "; PreparedStatement stt = conn.prepareStatement(qry); |

Paulo
Curtir tópico
+ 0Post mais votado
29/07/2010
1 2 3 4 5 6 7 8 | PrepareStatement sta = conn.prepareStatement("INSERT INTO...", Statement.RETURN_GENERATED_KEYS); sta.executeUpdate(); ResultSet rsID = sta.getGeneratedKeys(); if(rsID.next()) int id = rsID.getInt("id"); |
Paulo

Gostei + 1
Mais Posts
09/04/2009
João Santos
Gostei + 0
09/04/2009
Paulo
Gostei + 0
03/09/2009
Thiago Silva
1 2 3 4 5 6 7 8 | PreparedStatement ps = con.prepareStatement("insert into sistema.base " + "(nome, permissao) " + "values (?,?) returning id;"); ps.setString(1, base.getNome()); ps.setString(2, base.getPermissao()); int linhasAfetadas = ps.executeUpdate(); |
1 2 3 4 5 6 7 8 9 10 11 | PreparedStatement ps = con.prepareStatement("insert into sistema.base " + "(nome, permissao) " + "values (?,?) returning id;"); ps.setString(1, base.getNome()); ps.setString(2, base.getPermissao()); ResultSet rs = ps.[b]executeQuery()[/b]; if(rs.next()) int id = rs.getInt("id"); |
Gostei + 0
12/07/2010
Paulo
Gostei + 0
12/07/2010
Diogo Souza
Gostei + 0
12/07/2010
Thiago Silva
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)