【发布时间】:2012-10-15 07:49:47
【问题描述】:
我有一张这样的桌子:
CREATE TABLE test(
id integer not null default nextval('test_id_seq'::regclass),
client_name_id integer not null
);
外键约束:
"test_client_name_id_fkey" FOREIGN KEY (client_name_id) REFERENCES company(id) DEFERRABLE INITIALLY DEFERRED
和公司表:
CREATE TABLE company(
id integer not null default nextval('company_id_seq'::regclass),
company_name character varying(64) not null
)
现在我在测试表上有触发器,它使用提供的值 client_name_id 从公司表中获取 id,该值是通过将其与 company_name 匹配的字符串。但是当我插入记录 PostgreSQL 时返回错误,client_name_id 是 string 并且 int required 这是真的。
我如何告诉 PostgreSQL 不要验证插入的行,因为我已经在触发器中处理了它。
【问题讨论】:
标签: postgresql triggers insert foreign-keys postgresql-9.0