Problem with cursors in PL/pgsql - Mailing list pgsql-general

From murphy pope
Subject Problem with cursors in PL/pgsql
Date
Msg-id F194tN8zDo2QltZ4jN500006333@hotmail.com
Whole thread Raw
List pgsql-general
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.


pgsql-general by date:

Previous
From: Mike Mascari
Date:
Subject: Re: rowcount
Next
From: Joe Conway
Date:
Subject: Re: rowcount