1

我有以下表定义:

 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
);

当我执行以下查询时:

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

我从服务器收到此错误:

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

session_id_并且product_code_是相应类型的预初始化变量。

它应该如何擦除/修改一行,其单元成员变量满足给定条件?

4

1 回答 1

3

字段名称周围应该有括号以访问其子字段,如下所示:

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

请参阅文档中的访问复合类型

于 2013-01-28T10:34:30.183 回答