Scrolling/Updating Cursors

Поиск
Список
Период
Сортировка
От Kevin Wooten
Тема Scrolling/Updating Cursors
Дата
Msg-id CD436A08-9CCC-4964-866C-1A8F17707CBB@me.com
обсуждение исходный текст
Ответы Re: Scrolling/Updating Cursors
Список pgsql-general
My apologies for posting what is almost certainly somewhat of a repeat question but I have searched and attempted
everythingI can think of and cannot figure it out myself. 

The basic question is… Is it possible to get a scrollable cursor that, within a transaction, can insert/update/delete
rowsand see those changes? 

Why you ask? Because I am implementing the JDBC 4.1 spec and it (optionally) provides this ability and I’d like to
provideit if possible.  I thought just using a scrollable cursor with the isolation-level set to repeatable-read would
dothe trick but it still seems to see no changes (inserts/updates/deletes). 

Effectively I want roughly this sequence of events to work.

CREATE TABLE test (val text);

BEGIN;  # Could include ISOLATION LEVEL REPEATABLE READ

DECLARE c1 CURSOR FOR SELECT * FROM test;

FETCH ABSOLUTE 1;     # Returns No Row

INSERT INTO test VALUES (‘1');
INSERT INTO test VALUES (‘2');
INSERT INTO test VALUES (‘3');

FETCH ABSOLUTE 1;  # Returns “1”
FETCH NEXT:               # Returns “2"
DELETE FROM test WHERE CURRENT OF c1;  # Deletes “2”

FETCH ABSOLUTE 1;  # Returns “1”
FETCH NEXT;               # Returns “3”
UPDATE test SET val=‘4' WHERE CURRENT OF c1;
FETCH RELATIVE 0;    # Returns “4”

COMMIT;

Thanks!

-kw

В списке pgsql-general по дате отправления:

Предыдущее
От: Edson Richter
Дата:
Сообщение: Re: Postgres as In-Memory Database?
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: Postgres as In-Memory Database?