pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
record iteration within SQL
3+ messages / 2 participants
[nested] [flat]

* record iteration within SQL
@ 2002-02-25 22:08  Dan Langille <dan@langille.org>
  0 siblings, 2 replies; 3+ messages in thread

From: Dan Langille @ 2002-02-25 22:08 UTC (permalink / raw)
  To: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: record iteration within SQL
@ 2002-02-25 23:45  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Dan Langille <dan@langille.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2002-02-25 23:45 UTC (permalink / raw)
  To: dan@langille.org; +Cc: pgsql-sql

"Dan Langille" <dan@langille.org> writes:
> I don't under stand why I get this error:

> ERROR:  record stagingport has no field name

Would it help any if the error message used some quotes?

ERROR:  record "stagingport" has no field "name"

ie, there's no column named "name" in SELECT * FROM watch_list_staging
...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: record iteration within SQL
@ 2002-02-25 23:52  Dan Langille <dan@langille.org>
  parent: Dan Langille <dan@langille.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Dan Langille @ 2002-02-25 23:52 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

On 25 Feb 2002 at 18:45, Tom Lane wrote:

> "Dan Langille" <dan@langille.org> writes:
> > I don't under stand why I get this error:
> 
> > ERROR:  record stagingport has no field name
> 
> Would it help any if the error message used some quotes?
> 
> ERROR:  record "stagingport" has no field "name"
> 
> ie, there's no column named "name" in SELECT * FROM watch_list_staging ...

Yes Tom, it would.  That makes much more sense now.  Thank you.
-- 
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/ - practical examples




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-02-25 23:52 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-25 22:08 record iteration within SQL Dan Langille <dan@langille.org>
2002-02-25 23:45 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-02-25 23:52 ` Dan Langille <dan@langille.org>

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