Is it possible to run 2 querys at the same time without creating a FUNCTION?

Asked

Viewed 57 times

1

I have a problem where I need that when creating a new "location" on my system, automatically I need my "Room" table to have the "id_status" that is part of another changed table. This would be workable at bank level with a Function, but my question is, is is is it possible to treat this at application level.

My method of including in the lease table is currently like this.

What I wanted to do, was that at that moment I could run another Query updating the Rooms table.

    public void incluir(Locacao locacao) throws Exception {
    Connection conn = Conexao.conectarNoBancoDeDados();
    String sql = "INSERT INTO locacoes (id_quarto, id_cliente, data_entrada, data_saida, id_statusloc)" + " VALUES (?, ?, ?, ?, ?)";
    PreparedStatement ps = conn.prepareStatement(sql);

    try {
        ps.setLong(1, locacao.getQuarto().getIdQuarto());
        ps.setLong(2, locacao.getCliente().getIdCliente());
        ps.setDate(3, new java.sql.Date(locacao.getDataEntrada().getTime()));
        ps.setDate(4, new java.sql.Date(locacao.getDataSaida().getTime()));
        ps.setLong(5, locacao.getStatusLocacao().getIdStatusLoc());
        ps.executeUpdate();
    } catch (Exception e) {
        throw new Exception(e);
    } finally {
        Conexao.fecharConexao(conn, ps, null);
    }
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.