Error defining composite types and returning ROWTYPEs

From: Geoffrey Giesemann <geoffwa(at)iinet(dot)net(dot)au>
To: pgsql-general(at)postgresql(dot)org
Subject: Error defining composite types and returning ROWTYPEs
Date: 2005-06-18 11:17:47
Message-ID: d90vhi$t4e$1@sea.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

CREATE TABLE test_table (
some_column integer,
another_column text
);

CREATE TYPE test_type as (
some_type test_table.some_column%TYPE
);

Gives me:
ERROR: syntax error at or near "%" at character 62
LINE 2: some_type test_table.some_column%TYPE

I also can't define rowtypes as return types on functions:
CREATE OR REPLACE FUNCTION get_test_table_single()
RETURNS test_table%ROWTYPE AS $$
DECLARE
v_single test_table%ROWTYPE;
BEGIN
SELECT * INTO v_single FROM test_table LIMIT 1;
RETURN v_single;
END;
$$ LANGUAGE plpgsql;

Gives me:
ERROR: syntax error at or near "%" at character 65
LINE 2: RETURNS test_table%ROWTYPE AS $$

Can somebody tell me what I'm doing wrong? This is driving me insane.

Geoff

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GUNDUZ 2005-06-18 12:22:24 Re: libpq.so.3 problem, PostgreSQL >= 8.0.2 and RPM
Previous Message Jeffery Reedy 2005-06-18 05:54:59 Replication