Problem Using RowType Declaration with Table Domains - Mailing list pgsql-general

From George Weaver
Subject Problem Using RowType Declaration with Table Domains
Date
Msg-id 6F3A80F719B0427B82D68AA9660D2B38@d800
Whole thread Raw
Responses Re: Problem Using RowType Declaration with Table Domains
List pgsql-general
Hi all,

I have the following (very simplified) scenario:

CREATE DOMAIN orderstatus AS text NOT NULL DEFAULT 'Open';

ALTER DOMAIN orderstatus ADD CONSTRAINT orderstatus_valid
                CHECK (VALUE IN ('Open', 'Shipped', Cancelled'));

CREATE TABLE orders ( orderno serial
                                         , status orderstatus
                                         , PRIMARY KEY (orderno));

INSERT INTO orders (status) VALUES('Open'),('Open'),('Shipped');

CREATE OR REPLACE FUNCTION getOrder(int4)
RETURNS
orders
AS
$$DECLARE
orderno_in alias for $1;
saleorder orders%rowtype;
BEGIN
SELECT INTO saleorder * FROM orders WHERE orderno = orderno_in;
RETURN saleorder;
END;
$$
VOLATILE
LANGUAGE 'plpgsql';

test1=# select * from getorder(3);
ERROR:  domain orderstatus does not allow null values
CONTEXT:  PL/pgSQL function "getorder" line 4 during statement block local
variable initialization

Is there a way around this?

Thanks,
George


pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: Unable to determine what has a particular OID
Next
From: Greg Smith
Date:
Subject: Re: High Availability with Postgres