Subject | RE: [Firebird-Java] SP with returning value error |
---|---|
Author | Rick DeBay |
Post date | 2004-08-11T15:36:06Z |
If you're only getting back one result instead of multiple results, I'd
recommend using a CallableStatement. Retrieving a ResultSet instead of
out parameters requires the SUSPEND command in the stored procedure,
which means (AFAIK) that the SP won't finish and the driver won't commit
until the ResultSet is closed, either explicitly or implicitly.
-----Original Message-----
From: Francisco Antonio Vieira Souza
[mailto:franciscosouza2002@...]
Sent: Tuesday, August 10, 2004 1:33 PM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] SP with returning value error
Rick DeBay wrote:
importante, how it is working, it is not necessary to use the
CallableStatement, have a look:
PreparedStatement p = c.prepareStatement("SELECT * FROM
SP_SET_SALVAR_DOCUMENTO_RECEBER(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
p.setString(1, tipo_recebimento);
p.setString(2, id_tomador);
p.setString(3, documento_origem);
p.setString(4,documento_gerado);
p.setBigDecimal(5, perc_desconto);
p.setBigDecimal(6, perc_juros);
p.setBigDecimal(7, valor_desconto);
p.setBigDecimal(8, valor_receber);
p.setBigDecimal(9, valor_total);
p.setDate(10,data_emissao);
p.setTime(11,hora_emissao);
p.setDate(12, data_vencimento);
p.setString(13, descricao);
p.setString(14, boleto);
ResultSet rs = p.executeQuery();
if(rs.next())
{
numero_gerado = rs.getInt("DOCUMENTO_GERADO");
} rs.close();
p.close();
Yahoo! Groups Links
recommend using a CallableStatement. Retrieving a ResultSet instead of
out parameters requires the SUSPEND command in the stored procedure,
which means (AFAIK) that the SP won't finish and the driver won't commit
until the ResultSet is closed, either explicitly or implicitly.
-----Original Message-----
From: Francisco Antonio Vieira Souza
[mailto:franciscosouza2002@...]
Sent: Tuesday, August 10, 2004 1:33 PM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] SP with returning value error
Rick DeBay wrote:
> You left out the FROM keyword.Thank you for the answer, yes you were write, I had left out something
> And you may need to use a CallableStatement instead of
> PreparedStatement. I'm not to clear on that part, and would like
> clarification myself.
importante, how it is working, it is not necessary to use the
CallableStatement, have a look:
PreparedStatement p = c.prepareStatement("SELECT * FROM
SP_SET_SALVAR_DOCUMENTO_RECEBER(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
p.setString(1, tipo_recebimento);
p.setString(2, id_tomador);
p.setString(3, documento_origem);
p.setString(4,documento_gerado);
p.setBigDecimal(5, perc_desconto);
p.setBigDecimal(6, perc_juros);
p.setBigDecimal(7, valor_desconto);
p.setBigDecimal(8, valor_receber);
p.setBigDecimal(9, valor_total);
p.setDate(10,data_emissao);
p.setTime(11,hora_emissao);
p.setDate(12, data_vencimento);
p.setString(13, descricao);
p.setString(14, boleto);
ResultSet rs = p.executeQuery();
if(rs.next())
{
numero_gerado = rs.getInt("DOCUMENTO_GERADO");
} rs.close();
p.close();
Yahoo! Groups Links