Re: [SQL] Cursors..

2008-08-19 Thread Yura Gal
Take a look at http://www.postgresql.org/docs/8.3/interactive/plpgsql-cursors.html and you'll find answer you need. > I need to convert this cursor of Oracle to Postgres... > I wait for your help!! -- Best regards, Yuri. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make ch

[SQL] Cursors..

2008-08-18 Thread David Calle
Hi List, I need to convert this cursor of Oracle to Postgres... I wait for your help!! *declare** v_num_dep integer := &v_num_dep; v_cont integer:=0; cursor cursor_dep is select * from hr.employees where hr.employees.department_id = v_num_dep; reg_dep cursor_dep%rowtype; beg

Re: [SQL] cursors and sessions

2008-03-13 Thread Aaron Bono
On Thu, Mar 13, 2008 at 5:54 PM, chester c young <[EMAIL PROTECTED]> wrote: > is there any way to share a cursor between sessions? > > I have a costly query whose records need to be visited by in order by n > number of concurrent sessions, and am unable to find the best way of > doing this. > > I'

[SQL] cursors and sessions

2008-03-13 Thread chester c young
is there any way to share a cursor between sessions? I have a costly query whose records need to be visited by in order by n number of concurrent sessions, and am unable to find the best way of doing this. I'd almost like to write a daemon that hands out the next record, but that's a royal pain t

Re: [SQL] Cursors and recursion

2005-12-28 Thread Michael Fuhr
On Wed, Dec 28, 2005 at 04:37:21PM -0300, Don Croata wrote: > Please, if someone recalls a link, book, piece of code or anything with info > about this technique for PL/PgSQL (8.1), please let us know. We've been > searching into google, groups.google, http://archives.postgresql.org and > http://ww

Re: [SQL] Cursors and recursion

2005-12-28 Thread Don Croata
Please, if someone recalls a link, book, piece of code or anything with info about this technique for PL/PgSQL (8.1), please let us know. We've been searching into google, groups.google, http://archives.postgresql.org and http://www.postgresql.org/docs/8.1/interactive with no results. Most of the

Re: [SQL] Cursors and recursion

2005-12-28 Thread Michael Fuhr
On Wed, Dec 28, 2005 at 10:48:25AM -0500, Tom Lane wrote: > Don Croata <[EMAIL PROTECTED]> writes: > > It's a function who has a cursor and calls itself, but the problem raises > > after the first recursion, when PgSQL complains: > > > ERROR: cursor "cur" already in use > > > Are the cursors kep

Re: [SQL] Cursors and recursion

2005-12-28 Thread Tom Lane
Don Croata <[EMAIL PROTECTED]> writes: > It's a function who has a cursor and calls itself, but the problem raises > after the first recursion, when PgSQL complains: > ERROR: cursor "cur" already in use > Are the cursors kept globally? or cached like TEMP TABLE? Cursor names are global within a

[SQL] Cursors and recursion

2005-12-28 Thread Don Croata
Hi,   I've been trying to do recursion and cursors in PL/PgSQL (PostgreSQL 8.1). It's a function who has a cursor and calls itself, but the problem raises after the first recursion, when PgSQL complains:   ERROR:  cursor "cur" already in use   Are the cursors kept globally? or cached like TEMP TABL

Re: [SQL] cursors and for loops?

2004-04-15 Thread Jan Wieck
Just FYI, recent versions of PG use cursors internally for PL/pgSQL FOR loops. So there is no danger for a procedure to run out of memory when looping over a huge result set ... at least not because of that. Jan Dennis wrote: Tom Lane writes: Something like LOOP FET

Re: [SQL] cursors and for loops?

2004-04-13 Thread Richard Huxton
On Sunday 11 April 2004 19:46, Dennis wrote: > Tom Lane writes: > > Something like > > > > LOOP > > FETCH ...; > > EXIT WHEN NOT found; > > ... > > END LOOP; > > Thank you! I tried finding documentation on "found" in this context and > didn't come up with

Re: [SQL] cursors and for loops?

2004-04-11 Thread Dennis
Tom Lane writes: Something like LOOP FETCH ...; EXIT WHEN NOT found; ... END LOOP; Thank you! I tried finding documentation on "found" in this context and didn't come up with anything. Can you point me to where it is documented?

Re: [SQL] cursors and for loops?

2004-04-11 Thread Tom Lane
"Dennis" <[EMAIL PROTECTED]> writes: > I am wondering if I can use a cursor in a for loop. Something like LOOP FETCH ...; EXIT WHEN NOT found; ... END LOOP; should do it. regards, tom lane -

[SQL] cursors and for loops?

2004-04-11 Thread Dennis
Hello, I am wondering if I can use a cursor in a for loop. I haven't been able to get it to work. I am just beginning plpgsql and I am struggling here. I am trying to do this: create or replace function ttest(varchar) RETURNS varchar AS ' DECLARE parId ALIAS FOR $1; dennis varchar;

[SQL] CURSORS - Please help urgent.

2004-02-29 Thread Sumita Biswas (sbiswas)
The follow code gives me Error: DECLARE CURSOR_GET_ALL_CONFERENCE_RECORDS CURSOR FOR Select ConferenceType,CallManagerId,ClusterId,DestConversationId,AppConfId,Fina lDestination FROM Tmp_Conference; OPEN CURSOR_GET_ALL_CONFERENCE_RECORDS; FETCH FROM CURSOR_GET_ALL_CONFERENCE_RECORDS IN

Re: [SQL] cursors in plpgsql

2003-09-17 Thread Tomasz Myrta
Releases before 7.4 are spotty about supporting backwards scan of complex queries --- if you have a join or aggregate in the query, it likely won't work, yielding either strange errors or wrong answers. It will work if the top plan node in the query is a SORT, though, so a possible workaround is to

Re: [SQL] cursors in plpgsql

2003-09-17 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > I wanted to use some select result several times in pl/pgsql function. > Neither move backward 1 in test; > nor > execute ''move backward 1 in test''; > doesn't work. Releases before 7.4 are spotty about supporting backwards scan of complex queri

[SQL] cursors in plpgsql

2003-09-17 Thread Tomasz Myrta
Hi I wanted to use some select result several times in pl/pgsql function. DECLARE test refcursor; x record; BEGIN open test for select... fetch test into x; while found loop ...work... fetch test into x; end loop; ...rewind cursor using move... fetch test... Neither move backward 10

Re: [SQL] Cursors and backwards scans and SCROLL

2003-03-09 Thread Tom Lane
Rod Taylor <[EMAIL PROTECTED]> writes: > Enforcing spec seems like the least confusing mode to operate under, > especially given it could break simply by changing the plan -- which > happens automagically (seemingly random). Keep in mind though that complaints about the current bugs have been fair

Re: [SQL] Cursors and backwards scans and SCROLL

2003-03-09 Thread Rod Taylor
> I'm presently leaning to #2, even though it exposes implementation > details. I'm open to discussion though. Any preferences? Other ideas? How about a variable that turns on or off spec enforcement (case #1 or #2). On for 7.4, off for 7.5 the next release, and make it disappear after that. E

Re: [SQL] Cursors and backwards scans and SCROLL

2003-03-09 Thread Josh Berkus
Tom, > Postgres' implementation of cursors has always had a problem with doing > MOVE or FETCH backwards on complex queries. Coincidnetally enough, I was just chatting with one of my contractors yesterday about how the one thing that Transact-SQL has to offer is a really good cursor implementa

[SQL] Cursors and backwards scans and SCROLL

2003-03-09 Thread Tom Lane
Postgres' implementation of cursors has always had a problem with doing MOVE or FETCH backwards on complex queries. It works okay for simple seqscans and indexscans, but fails for plans involving joins, aggregates, and probably other cases. This happens because the executor routines for those pla

Re: [SQL] Cursors in plpgsql

2001-04-17 Thread Josh Berkus
Preeti, > Is there a command in plpgsql similar to %NOTFOUND of oracle? Cursors are not currently supported for PL/pgSQL. There are plans to include them for and upcoming version of Postgres. But dont' wait your application on it. > i want to write a load script which takes each row from the

[SQL] Cursors in plpgsql

2001-04-16 Thread Preeti Kamble
Hi Is there a command in plpgsql similar to %NOTFOUND of oracle? i want to write a load script which takes each row from the temporary table, do some processing and insert into actual tables. Any idea how i can accomplish this??? thank you regards Preeti ---(end of bro