estou com problema quando tento executar uma stored procedure, estou usando firebird.
Erro:
java.sql.SQLException: invalid column index
at org.firebirdsql.jdbc.FBPreparedStatement.getField(FBPreparedStatement.java:237)
at org.firebirdsql.jdbc.FBPreparedStatement.setFloat(FBPreparedStatement.java:191)
at br.com.rodoac.estoque.model.Pesquisa.runProcedure(Pesquisa.java:135)
Class.forName(Constants.DRIVER);
Connection con = DriverManager.getConnection(Constants.URL+
Constants.GDB,
Constants.USER,
Constants.PASS);
CallableStatement cs;
cs = con.prepareCall("{call RET_PROD(?,?,?)");
cs.setInt(1, codProduto);
cs.setFloat(2, estoque);
cs.registerOutParameter(3, Types.VARCHAR);
cs.execute();
Stored Procedure: (a stored procedure ja foi testada com o ibx no delphi e funciona perfeitamente).
CREATE PROCEDURE RET_PROD(
COD_PROD INTEGER,
ESTQ FLOAT)
RETURNS (
OK VARCHAR(1))
AS
DECLARE VARIABLE ESTQ_ATUAL FLOAT;
begin
ESTQ_ATUAL = 0;
OK = 'N';
select estoque from produtos
where codigo = :cod_prod
into :estq_atual;
if (estq_atual > 0) then
begin
update produtos set estoque = :estq_atual - :estq where codigo = :cod_prod;
OK = 'S';
end
suspend;
end