RubyODBC error codes when using prepared statements

  • Thread starter Daniel de Angelis Cordeiro
  • Start date
D

Daniel de Angelis Cordeiro

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
 
D

Daniel de Angelis Cordeiro

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top