Re: accessing fully qualified fields in records in PLPGSQL? - Mailing list pgsql-general

From Darren Ferguson
Subject Re: accessing fully qualified fields in records in PLPGSQL?
Date
Msg-id Pine.LNX.4.10.10203251151220.16838-100000@thread.crystalballinc.com
Whole thread Raw
In response to accessing fully qualified fields in records in PLPGSQL?  ("Oberpriller, Wade D." <oberpwd@nsc-msg01.network.com>)
Responses pg_dump-ing tables and their sequences  (Michael Adler <adler@glimpser.org>)
List pgsql-general
dev=> CREATE FUNCTION test() RETURNS INTEGER AS '
dev'> DECLARE
dev'>   rec RECORD;
dev'>   val INTEGER;
dev'> BEGIN
dev'>   FOR rec IN SELECT oid FROM inv_locations LOOP
dev'>      val := rec.oid;
dev'>   END LOOP;
dev'> RETURN val;
dev'> END;' LANGUAGE 'plpgsql';
CREATE
dev=> select test();
  test
--------
 534321
(1 row)

Did not see your declare etc but this one works. Returns the final oid for
that table

HTH

Darren Ferguson

On Mon, 25 Mar 2002, Oberpriller, Wade D. wrote:

> How does one access a field in a record from a query like so:
>
> FOR REC IN SELECT myTable.oid FROM myTable, yourTable WHERE (myTable.id =
> yourTable.id) LOOP
>     VAL := REC.oid;
>     VAL := REC.myTable.oid;
> END LOOP;
>
> I get errors in PLPGSQL compilation for both the assignment statements
> above. What is the correct way to get the myTable oid in the REC record?
>
> Wade Oberpriller                 http://www.storagetek.com
> Software Development             Phone: (763) 424-1538
> StorageTek: MRDC                        (800) 328-9108 ext. 1538
> wade_oberpriller@storagetek.com  Fax:   (763) 391-1095
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>


pgsql-general by date:

Previous
From: "Oberpriller, Wade D."
Date:
Subject: accessing fully qualified fields in records in PLPGSQL?
Next
From: "Thomas F. O'Connell"
Date:
Subject: Re: logging all queries in 7.1.3