RubyODBC error codes when using prepared statements

Hi,

I’m using Ruby ODBC (with unixodbc and Postgresql).
RubyODBC is loosing my error codes when running prepared statements.

When I execute a faulty SQL command using ODBC::Database.run() or
ODBC::Database.do() I get the following native error:
23505 (7) [unixODBC]ERROR: duplicate key value violates unique
constraint “<pk_name>”

However, when I execute the same SQL command using a prepared
statement, I get the following internal error:
INTERN (0) [RubyODBC]Stale ODBC::Statement

Is there a way to recover the type of the native error when executing
a prepared statement?

Thanks in advance,
Daniel

Hi,

After some debugging, I found that I was trying to reuse a prepared
statement that already had returned an error in a previous execution.

So, at the first execution I get the native error:
23505 (7) [unixODBC]ERROR: duplicate key value violates unique
constraint “<pk_name>”

And when I try to reuse the statement (with parameters that should
result in a successful execution) I get the internal error:
INTERN (0) [RubyODBC]Stale ODBC::Statement

Is it possible to reuse prepared statements after an error in
RubyODBC? If so, how?

Thanks,
Daniel

On Wed, Mar 2, 2011 at 11:22, Daniel de Angelis Cordeiro

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs