Problem Using RowType Declaration with Table Domains
| От | George Weaver |
|---|---|
| Тема | Problem Using RowType Declaration with Table Domains |
| Дата | |
| Msg-id | 6F3A80F719B0427B82D68AA9660D2B38@d800 обсуждение исходный текст |
| Ответы |
Re: Problem Using RowType Declaration with Table Domains
|
| Список | 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 по дате отправления: