How to use record variable with non-null domain in plpgsql

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to use record variable with non-null domain in plpgsql
Date: 2015-08-22 15:27:52
Message-ID: 1C63F0F484C94229928C0F65AB19296E@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm looging for a way to use tebool type records in plpgsql method starting from Postgres 9.1
I tried code below but got error

domain tebool does not allow null values
Domain tebool default value is false so plpgsql must assing false to it and should not throw error.

How to fix this so that such record variable can created ?

Andrus.

CREATE DOMAIN tebool AS bool DEFAULT false NOT NULL;
create temp table test ( test tebool ) on commit drop ;

CREATE OR REPLACE FUNCTION test()
RETURNS numeric AS $$

DECLARE
r_test test;
begin

return 0;
end; $$ language plpgsql;

select test();

Posted also in

http://stackoverflow.com/questions/32157166/how-to-fix-domain-tebool-does-not-allow-null-values-in-plpgsql-function

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-08-22 15:43:48 Re: How to use record variable with non-null domain in plpgsql
Previous Message Melvin Davidson 2015-08-22 15:15:07 PostgreSQL Developer Best Practices