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.