Skip site navigation (1) Skip section navigation (2)

Passing a row

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Passing a row
Date: 2004-03-26 15:26:16
Message-ID: 200403261026.16099.terry@esc1.com (view raw or flat)
Thread:
Lists: pgsql-general
PostgreSQL Version:
PostgreSQL 7.3.4 on i386-redhat-linux-gnu, compiled by GCC 
i386-redhat-linux-gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

I'm trying to pass a row into a function and cannot get it to work. The code 
doing the calling is (logs_preupd_func):
DECLARE
    test    RECORD;
...
...

    SELECT INTO test * FROM logs WHERE order_num = new.order_num;
    PERFORM valid_event_time (test);

The defintition for valid_event_time ():

CREATE OR REPLACE FUNCTION valid_event_time (logs)
    RETURNS text AS '
.
.
.
I get the following error:
WARNING:  Error occurred while executing PL/pgSQL function logs_preupd_func
WARNING:  line 131 at assignment
ERROR:  Attribute "test" not found

This example in the docs indicates that this can be done as in:
CREATE FUNCTION use_two_tables(tablename) RETURNS TEXT AS '
DECLARE
    in_t ALIAS FOR $1;
    use_t table2name%ROWTYPE;
BEGIN
    SELECT * INTO use_t FROM table2name WHERE ... ;
    RETURN in_t.f1 || use_t.f3 || in_t.f5 || use_t.f7;
END;
' LANGUAGE 'plpgsql';

Can anybody show me the error of my ways?

Thanks...
-- 
 Work: 1-336-372-6812
 Cell: 1-336-363-4719
email: terry(at)esc1(dot)com

Responses

pgsql-general by date

Next:From: Guy FraserDate: 2004-03-26 15:44:50
Subject: Re: PHP or JSP? That is the question.
Previous:From: Patrick HatcherDate: 2004-03-26 14:28:31
Subject: Where are these tables??

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group