pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Langille <dan@langille.org>
To: pgsql-sql@postgresql.org
Subject: record iteration within SQL
Date: Mon, 25 Feb 2002 17:08:56 -0500
Message-ID: <200202252208.g1PM8wk69093@lists.unixathome.org> (raw)

I'm using the example at http://www.postgresql.org/idocs/index.php?plpgsql-

description.html under section "24.2.7.3. Iterating Through Records" as 
the 
basis for this code.  I don't under stand why I get this error:

# select WatchListStagingProcess(1);
NOTICE:  Error occurred while executing PL/pgSQL function 
watchliststagingprocess
NOTICE:  line 8 at SQL statement
ERROR:  record stagingport has no field name

cheers.

CREATE FUNCTION WatchListStagingProcess(int4) RETURNS int4 AS '
    DECLARE
        WatchListID ALIAS for $1;

        stagingport RECORD;

    BEGIN
        FOR stagingport IN SELECT * FROM watch_list_staging WHERE 
watch_list_id = WatchListID LOOP
            INSERT INTO watch_list_staging_results (watch_list_staging_id, 
element_id)
                SELECT stagingport.ID, element.id
                  FROM ports, element
                 WHERE element.name = stagingport.name
                   AND element.id   = ports.element_id;
        END LOOP;
    END
' LANGUAGE 'plpgsql';
-- 
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/ - practical examples




view thread (3+ messages)  latest in thread

Message-ID: <200202252208.g1PM8wk69093@lists.unixathome.org>
Permalink:  ../200202252208.g1PM8wk69093@lists.unixathome.org/
Also on:    postgresql.org/message-id/200202252208.g1PM8wk69093@lists.unixathome.org

 · 

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: dan@langille.org
  Subject: Re: record iteration within SQL
  In-Reply-To: <200202252208.g1PM8wk69093@lists.unixathome.org>

* 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