1

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.