记录“新”没有字段“治愈”postgreSQL

Σωκ*_*γος 6 postgresql

所以这就是事情,我有两个表:apointments(带有单个 p)和医疗文件夹,我得到了这个

错误:记录“new”没有字段“cure”上下文:SQL语句“插入到medical_folder(id,“patient_AMKA”,cure,drug_id)值(new.id,new。“patient_AMKA”,new.cure,new.drug_id )" PL/pgSQL 函数 new_medical() 第 3 行在 SQL 语句

create trigger example_trigger after insert on apointments 
for each row execute procedure new_medical();

create or replace function new_medical()
returns trigger as $$
begin 
if apointments.diagnosis is not null then
insert into medical_folder(id,"patient_AMKA",cure,drug_id)
values(new.id,new."patient_AMKA",new.cure,new.drug_id);
return new;
end if;
end;
$$ language plpgsql;


insert into apointments(id,time,"patient_AMKA","doctor_AMKA",diagnosis)
values('30000','2017-05-24 0 
07:42:15','4017954515276','6304745877947815701','M3504');
Run Code Online (Sandbox Code Playgroud)

我已经检查了多次,我所有的表和列都存在请帮忙!谢谢!

表结构是:

create table medical_folder (
  id      bigInt,
  patient bigInt,
  cure    text,
  drug_id bigInt);

create table apointments (
  id      bigint,
  time    timestamp without time zone,
  "patient_AMKA" bigInt,
  "doctor_AMKA"  bigInt);
Run Code Online (Sandbox Code Playgroud)

vto*_*ino 9

我面临着同样的问题。改变:

values(new.id,new."patient_AMKA",new.cure,new.drug_id);
Run Code Online (Sandbox Code Playgroud)

到:

values(new.id,new."patient_AMKA",new."cure",new."drug_id");
Run Code Online (Sandbox Code Playgroud)