SV: Survey: Do you use positioned updates from DBI ?

From: Henrik Tougaard (ht000_at_foa.dk)
Date: 01/17/05


To: 'Dean Arnold' <darnold@presicient.com>, DBI-users <dbi-users@perl.org>
Date: Mon, 17 Jan 2005 07:54:42 +0100


> I'm hoping to get some feedback on how often updatable
> cursors are being used in DBI apps ?
We use it from timne to time. I have implemented them in DBD::Ingres (see
ing_readonly in the DBD::Ingres docs).

> My understanding is that "standard" embedded SQL uses a syntax like
> DECLARE CURSOR cursor-name AS select-stmt FOR UPDATE;
> OPEN cursor-name;
> FETCH cursor_name INTO ...;
> UPDATE table SET ... WHERE CURRENT OF cursor-name;
> (or DELETE FROM table WHERE CURRENT OF cursor-name)
With DBD::Ingres the syntax is:
         $sth = $dbh->prepare("SELECT a,b,c FROM t FOR UPDATE OFb");
         $sth->execute;
         $row = $sth->fetchrow_arrayref;
         $dbh->do("UPDATE t SET b='1' WHERE CURRENT OF $sth->{CursorName}");
where I assume that a select without a 'FOR UPDATE OF column' clause is
read-only.

Henrik Tougaard
DBD::Ingres maintainer.