Search Postgresql Archives

Problem Using RowType Declaration with Table Domains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux