Problem with cursors in PL/pgsql

Started by murphy popealmost 24 years ago2 messagesgeneral
Jump to latest
#1murphy pope
pope_murphy@hotmail.com

I'm trying out some of the new cursor support in PL/pgSQL version 7.1.2.

For some reason, I'm getting an error (in the function below) on the line:
"OPEN curs ($1 );"

CREATE FUNCTION test_cursor2( OID ) RETURNS INTEGER AS '
DECLARE
curs CURSOR ( owner_id OID ) FOR SELECT typname, typowner FROM pg_type
WHERE typowner = owner_id;
r RECORD;
cnt INTEGER := 0;
BEGIN

OPEN curs ( $1 );

LOOP

FETCH curs INTO r;

EXIT WHEN NOT FOUND;

RAISE NOTICE ''typname %, typowner %'', r.typname, r.typowner;

cnt := cnt + 1;

END LOOP;

RETURN( cnt );

END;
' LANGUAGE 'plpgsql';

If written as:
OPEN curs ( $1 );
I get: mismatched parenthesis

(I peeked at the grammar - it seems to remove the leading paren).

If written as:
OPEN curs (( $1 );
I get: parse error at or near ""

If written as:
OPEN curs ( 3 );
I get: mismatched parenthesis

Any ideas? Thanks.
-- Murphy

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

#2murphy pope
pope_murphy@hotmail.com
In reply to: murphy pope (#1)
Re: Problem with cursors in PL/pgsql

Never mind. It turned out to be a problem in the PL/pgSQL parser. I'll see
if I can submit a patch. Thanks.

-- Murphy

I'm trying out some of the new cursor support in PL/pgSQL version 7.1.2.

For some reason, I'm getting an error (in the function below) on the line:
"OPEN curs ($1 );"

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com