문제

I have the following table definition:

 CREATE TYPE product_limit_type AS (
    product_code varchar(5),
    limit_type varchar(30),
    limit_value numeric(4,0)
);

CREATE TABLE rule_locks (
    session_id bigint,
    rule_id bigint,
    product_limit product_limit_type
);

When I execute the following query:

DELETE FROM rule_locks
WHERE (session_id=session_id_ AND product_limit.product_code=product_code_);

I get this error from the server:

ERROR:  missing FROM-clause entry for table "product_limit"
LINE 1: ...FROM rule_locks WHERE (session_id=session_id_ AND product_li...
                                                         ^

session_id_ and product_code_ are pre-initialized variables of corresponding types.

How is it supposed to erase/modify a row, whose cell member variable satisfies given condition?

도움이 되었습니까?

해결책

There should be parentheses around the field's name to access its subfields, as in:

DELETE FROM rule_locks WHERE (session_id=session_id_
     AND (product_limit).product_code=product_code_);

See Accessing Composite Types in the documentation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top