Good, I have a Web application in which the front end is javaScript and the back java, which connects to SQL Server, I have an SP which queries the data on a table, which if not generated a function, the question is that the web screen shows me the generated data, that is, the sp works
But it does not record the data in the database, it generates them, it queries them about the table in modified theory but it does not save them, but if I run from the sql console it goes perfectly. The SQL code is as follows:
ALTER PROCEDURE [dbo].[SPC_PeriodoTasaObtener]
(
@idInmueble int,
@anio int,
@idContribuyente int
)
AS BEGIN
declare @valores int
set @valores = (select COUNT(idDeuda) from ValoresPeriodoTasa where
idInmueble=@idInmueble and anio = @anio)
if @valores = 0 begin
insert into ValoresPeriodoTasa(idDeuda,idInmueble,anio,periodo,montoPeriodo,primerVencimiento,segundoVencimiento,estado,codigoPeriodo)
select codigoDeduda,idInmueble,anioDeuda,periodo,montoperiodo,primerVence,segundoVence,estadoDeuda,codigoPeriodo
from dbo.GeneraDeuda(@idContribuyente,@idInmueble,@anio)
end
select idDeuda,idInmueble,anio,periodo,montoPeriodo,primerVencimiento,segundoVencimiento,estado,codigoPeriodo
from ValoresPeriodoTasa
where idInmueble=@idInmueble and anio=@anio
end
I hope you can guide me to solve my problem. thanks
public List<EstadoPeriodosTasa> obtenerPeriodos(int idInmueble, int anio, int idContribuyente) {
List<EstadoPeriodosTasa> tasa = new ArrayList<EstadoPeriodosTasa>();
Connection connection = DBConection.getConnection();
PreparedStatement st = null;
ResultSet resultSet = null;
try{
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
st = connection.prepareStatement("SPC_PeriodoTasaObtener " + idInmueble + ", " + anio + ", " + idContribuyente);
resultSet = st.executeQuery();
while (resultSet.next()) {
EstadoPeriodosTasa elem = new EstadoPeriodosTasa();
elem.setIdDeuda(resultSet.getInt(1));
elem.setIdInmueble(resultSet.getInt(2));
elem.setAnio(resultSet.getInt(3));
elem.setPeriodo(resultSet.getString(4));
elem.setMontoPeriodo(resultSet.getDouble(5));
elem.setPrimerVence(dateFormat.format(resultSet.getDate(6)));
elem.setSegundoVence(dateFormat.format(resultSet.getDate(7)));
elem.setEstadoPeriodo(resultSet.getString(8));
elem.setCodigoPeriodo(resultSet.getInt(9));
tasa.add(elem);
}
return tasa;
}catch (SQLException e) {
e.printStackTrace();
}finally{
try {
DBConection.cerrarConexion(resultSet,st,connection);
} catch (SQLException e) {
e.printStackTrace();
}
}
return tasa;
}
this is the java code that calls the sp, I already have other sp that I pass the parameters and they record me perfect, this case is very particular xq step the parameters a function is executed, generates the new fields, returns them to me but it does not record them, but if I execute from sql it records them and also returns them