Is it possible to call function in exclude contrains to return only specific column

50 views Asked by At

I'm trying to implement exclude constraint and I have written the function which returns more than one separate parameters (types: character varying). What I want is to call this function twice, but choose different columns, something like this:

... EXCLUDE USING GIST (

(make_rule_test(contract_id, customer_id, email_address,vin)).email_address_OUT WITH =,

(make_rule_test(contract_id, customer_id, email_address,vin)).vin_OUT WITH =

)

But I got an error

: ----- ERROR: syntax error at or near "."

Function should follow some logic like this: IF (contract_id + customer_id) is null AND email_address is not null AND vin is not null THEN vin and email must be unique at the same level. Function should return vin and email. This is my function:

create OR REPLACE function make_rule_test(IN contract_id integer,IN customer_id character varying(30), IN email_address character varying(255), IN vin character varying(17),
                                         OUT email_address_OUT character varying(255), OUT vin_OUT character varying(17))
as
$$
begin

    if(contract_id is null and customer_id is null and email_address is not null and vin is not null)   
    then   
        email_address_OUT := email_address;
        vin_OUT := vin;
    END IF;
end;        
$$
LANGUAGE 'plpgsql' IMMUTABLE;

My question is: Is it possible to call this function to return only specific column? I saw GIST doesn't support record type?

0

There are 0 answers