"Thomas, Eldho" wrote:

> I am reading through a set of rows using DBI, fetchrow_array and a WHILE
> loop. For each loop, I have to do some updates and do a commit. But, this
> commit closes the cursor and when I try to fetch the next row, I get the
> error "FETCH  ATTEMPTED ON AN UNOPENED CURSOR".
>
> I know that this can be overcome in Informix 4GL by specifying "with hold"
> while opening the cursor. How is this done using DBI ?
>

Eldho,

The DBD::Informix docs are a bit off on this one.   The docs state that
attibutes to prepare are not supported, but support was added for a "WITH HOLD"
cursor.

      According to the DBI specification, the prepare call accepts an
      optional attributes parameter that is a reference to a hash.  At the
      moment, no parameters are recognized.  It would be reasonable to add,
      for example, {ix_CursorWithHold => 1} to specify that the cursor
      should be declared WITH HOLD.  Similarly, you could add
      {ix_BlobLocation => 'InFile'} to support per-statement blob location,
      and {ix_ScrollCursor => 1} to support scroll cursors.



>
> This is what my program looks like -
>
> $dbh = DBI->connect("dbi:Informix:database", undef, undef, {PrintError => 1,
> AutoCommit => 0}) || die Could not connect to flm database";
> $sth = $dbh->prepare("SQL Statement");

Change your prepare to:

$sth = $dbh->prepare("SQL Statement", {'ix_CursorWithHold' => 1});

and all should be good.


Hope this helps...

Bill


>
> $sth->execute;
>
> while (($value) = $sth->fetchrow_array)
> {
>    Update Statement....
>    Update Statement....
>    $dbh->commit;
> }
>
> $sth->finish;
> $dbh->disconnect;
>
> Thank you very much.
>
> Eldho Thomas
> Enterprise Rent-A-Car

--
Bill Rothanburg ([EMAIL PROTECTED])
Senior Infrastructure Engineer
DHL Regional Services, Inc.
Fort Lauderdale, FL  USA


Reply via email to