On Mon, 17 Jan 2005 07:54:42 +0100, Henrik Tougaard <[EMAIL PROTECTED]> wrote:
> > 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.
That code should also work in DBD::Informix -- which also (obviously)
supports them.
IDS (Informix Dynamic Server) marginally complicates things because in
a MODE ANSI database, all cursors (on a single table, without ORDER
BY, ...) can be used for update - as required by the ISO (ANSI) SQL
standard. So, the FOR UPDATE clause is not always mandatory in
Informix - but operationally, the UPDATE statement would simply fail
if the cursor is not updatable, and would work if it is. In a
non-ANSI database, the FOR UPDATE clause is mandatory.
You may go back to sleep now - the first paragraph is all you really
needed to know.
--
Jonathan Leffler <[EMAIL PROTECTED]> #include <disclaimer.h>
Guardian of DBD::Informix - v2003.04 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."