pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Tony G. Harris <tgharris_1@juno.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Trouble porting a Oracle PL/SQL procedure to PL/pgSQL
Date: Mon, 16 Jun 2003 19:17:57 -0700 (PDT)
Message-ID: <20030616191549.W78774-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <20030616.205744.-16302819.1.tgharris_1@juno.com>


On Mon, 16 Jun 2003, Tony G. Harris wrote:

> Hello.  I'm using PostgreSQL to learn SQL and SQL-based languages.  The
> text I'm using (SAMS Teach Yourself SQL in 21 Days, 3rd.ed.) references
> Oracle in its examples, though I can usually get PostgreSQL to work
> almost as well.
>
> Well, I'm almost to the end of the book and I'm trying to port some of
> the book's PL/SQL examples to PL/pgSQL, with mixed success.  In this
> case, I translated
>
> BEGIN
>         DECLARE
>                   UnknownPayType EXCEPTION;
>                   CURSOR pay_cursor IS
>                    SELECT name, pay_type, pay_rate, eff_date, sysdate,
> rowid
>                    FROM pay_table;
>                   IndRec pay_cursor%ROWTYPE;
>           . . .
> END;
> /
>
> to this:
>
> CREATE OR REPLACE FUNCTION update_pay() RETURNS VOID AS '
>          DECLARE
>           pay_cursor CURSOR IS
>            SELECT name, pay_type, pay_rate, eff_date, current_date, oid
>            FROM pay_table;
>           IndRec pay_cursor%ROWTYPE;
>           cOldDate DATE;
>         . . .
>         END;
> '
> LANGUAGE 'plpgsql';
>
> The problem is, when I call the function, I get:
>
> sql-practice=# select update_pay();
> ERROR:  pay_cursor: no such class
> WARNING:  plpgsql: ERROR during compile of update_pay near line 2
> WARNING:  plpgsql: ERROR during compile of update_pay near line 2
> ERROR:  pay_cursor: no such class
>
> I tried several ways of defining pay_cursor, with the same result.
> What am I to do?

I think it's complaining because you can't use pay_cursor%ROWTYPE.  Maybe
declaring IndRec as being of type record may work (don't know for
certain).





view thread (4+ messages)  latest in thread

Message-ID: <20030616191549.W78774-100000@megazone23.bigpanda.com>
Permalink:  ../20030616191549.W78774-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20030616191549.W78774-100000@megazone23.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, tgharris_1@juno.com
  Subject: Re: Trouble porting a Oracle PL/SQL procedure to PL/pgSQL
  In-Reply-To: <20030616191549.W78774-100000@megazone23.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox