Re: Me And My Database - Mailing list pgsql-general

From Leif B. Kristensen
Subject Re: Me And My Database
Date
Msg-id 200606141135.12834.leif@solumslekt.org
Whole thread Raw
In response to Re: Me And My Database  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Me And My Database
List 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

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Me And My Database
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Me And My Database