Re: with hold cursor in perl dbi
Posted in 2008
dcruncher4@aim.com wrote: > In article <48018B83.1030208@earthlink.net>, Jonathan Leffler says... >> dcruncher4@aim.com wrote: >>> It seems perl DBI/DBD for Informix does not support cursors WITH HOLD if >>> AutoCommit is set to 0. >> Patches welcome. >> >> Actually, with hold cursors don't work well with DBI's semantics. >> And there's no easy way to add them to the system. >> And they are used automatically in some circumstances - when autocommit >> is on. > > does WITH HOLD not work with other databases also? Do you mean other DBMS? I'm not sure, but I think not. > Of course the workaround is very simple. Make two connections. One for > reading and one for writing. Apart from the fact that you can make only tcp > connection , there is no other pain with this. Apart from the fact that the one connection can lock rows so that the other can't access them, yeah, you can try that. Anyway, DBD::Informix documentation (perldoc DBD::Informix) says: The prepare call accepts an optional attributes parameter that is a reference to a hash. Starting with version 1.03.PC1, the following attributes are recognized: {ix_InsertCursor => 1, ix_ScrollCursor => 1, ix_CursorWithHold => 1} The ix_ScrollCursor is a placeholder that may become unnecessary with a future revision of DBI. The ix_CursorWithHold attribute is only of relevance if AutoCommit is disabled. When AutoCommit is enabled, all cursors have to be WITH HOLD (just one more reason to hate AutoCommit). $sth = $dbh->prepare("SELECT id, name FROM tablename", {'ix_CursorWithHold' => 1}); After the cursor is opened ($sth->execute), it is not closed by $dbh->commit(). Either fetch all the rows or use $sth->finish() to close it. I've not gone poking to see which tests test that, but the tests all pass so either the test is wrong and you have a bug report to make, or the code works. Your bug report will include a minimal example script that demonstrates the problem. At some point, I'll do some investigation too, but without a nice crisp bug report to motivate me, it may be some time before I get to look at it. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2008.0229 -- http://dbi.perl.org/ publictimestamp.org/ptb/PTB-2997 whirlpool 2008-04-14 03:00:06 BD49B1CFF89C5C22307711EECC0CC21C4FDB2F17AB70B8D5D5A96090F651644BA6936E F17DF6CF87B582CBBCB3674E270B3FE49AFDB9E843EBC10F5A00070D7