Re: Me And My Database

From: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Me And My Database
Date: 2006-06-14 09:35:12
Message-ID: 200606141135.12834.leif@solumslekt.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-general

On Wednesday 14. June 2006 11:09, Martijn van Oosterhout wrote:
>IIRC, if you just declare src as type "record" you can select any
>fields you like. AIUI, declaring a row to be of a specific type is
> only really important if you plan to return it or pass it to another
> function.

I tried:

CREATE OR REPLACE FUNCTION get_source_text(integer) RETURNS TEXT AS $$
DECLARE
src RECORD;
mystring TEXT;
BEGIN
SELECT (source_id, parent_id, large_text)
FROM sources INTO src WHERE source_id = $1;
mystring := src.large_text;
IF src.parent_id <> 0 THEN
mystring := get_source_text(src.parent_id) || ' ' || mystring;
END IF;
RETURN mystring;
END;
$$ LANGUAGE plpgsql;

But now I get this error message:

Query failed: ERROR: record "src" has no field "large_text" CONTEXT:
PL/pgSQL function "get_source_text" line 7 at assignment

PostgreSQL version 8.0.8.
--
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-06-14 09:38:30 Re: Me And My Database
Previous Message Martijn van Oosterhout 2006-06-14 09:09:01 Re: Me And My Database

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-06-14 09:38:30 Re: Me And My Database
Previous Message Martijn van Oosterhout 2006-06-14 09:09:01 Re: Me And My Database