Hi,
Does anyone know how to declare arrays of custom types? The
documentation says:
As discussed earlier, PostgreSQL fully supports arrays of
base types. Additionally, PostgreSQL supports arrays of user-defined
types as well. When you define a type, PostgreSQL automatically
provides support for arrays of that type. For historical reasons, the
array type has the same name as the user-defined type with the
underscore character _ prepended.
When I run the following code:
CREATE TYPE TEST_TYPE AS (
ID INTEGER,
CODE VARCHAR(40)
);
CREATE OR REPLACE FUNCTION Test1( ) RETURNS TEST_TYPE[20] AS'
DECLARE
aoTesttype TEST_TYPE[20];
BEGIN
RETURN aoTestType;
END;' LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION Test2( ) RETURNS _TEST_TYPE AS'
DECLARE
aoTesttype _TEST_TYPE;
BEGIN
RETURN aoTestType;
END;' LANGUAGE 'plpgsql';
I get:
psql:Supplements.sql:34: ERROR: Type "test_type[]" does not exist
psql:Supplements.sql:41: ERROR: Type "_test_type" does not exist
Can anyone help?
Thanks in advance.
Matthew