后来在SQL中,我有了这个:
INSERT INTO s1_contact_person (name_and_address_id, contact_person_id, name, add_by, add_date, change_by, change_date )
SELECT MAX(tblPI.port_id), '1', :new.port_name, 'ANY USER', 'ANY USER', SYSDATE
FROM gtt_possible_port_ids tblPI, s1_contact_person cp
WHERE tblPI.serial_nbr = :new.serial_nbr
GROUP BY tblPI.serial_nbr, :new.port_name, cp.add_by, cp.change_by;
我添加了这一部分s1_contact_person cp
,因此我可以引用add_by并进行更改,但会收到类似的错误。
错误消息是:
LINE/COL ERROR
--------- -------------------------------------------------------------
121/8 PL/SQL: SQL Statement ignored
140/18 PL/SQL: ORA-00904: "CHANGE_BY": invalid identifier
Errors: check compiler log
s1_contact_person表是:
CREATE TABLE s1_contact_person (
name_and_address_id varchar2(10) not null,
contact_person_id varchar2(10) not null,
name varchar2(50 char) null,
position_code varchar2(10) null,
phone_nbr varchar2(32) null,
phone_ext varchar2(5) null,
fax_nbr varchar2(32) null,
toll_free_phone_nbr varchar2(32) null,
e_mail varchar2(128) null,
notes varchar2(250 char) null,
add_by varchar2(40) DEFAULT user not null,
add_date date DEFAULT sysdate not null,
change_by varchar2(40) DEFAULT user not null,
change_date date DEFAULT sysdate not null,
op_software_interface varchar2(30) null,
trader_id varchar2(10) null,
mobile_phone_nbr varchar2(32) null,
web_address varchar2(250) null,
epa_contact_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_epa_contact_flag CHECK (epa_contact_flag IN ('Y','N')),
payment_advice_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_payment_adv_email_flag CHECK (payment_advice_email_flag IN ('Y','N')),
purchase_settlement_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_pc_settle_email_flag CHECK (purchase_settlement_email_flag IN ('Y','N')),
sales_settlement_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_sc_settle_email_flag CHECK (sales_settlement_email_flag IN ('Y','N')),
sop_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_sop_email_flag CHECK (sop_email_flag IN ('Y','N')),
ar_interest_invoice_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_ar_int_inv_email_flag CHECK (ar_interest_invoice_email_flag IN ('Y','N')),
ar_withdraw_notice_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_ar_with_not_email_flag CHECK (ar_withdraw_notice_email_flag IN ('Y','N')),
inactive_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_inactive_flag CHECK (inactive_flag IN ('Y','N')),
sop_confirmation_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_sop_confirmation_flag CHECK (sop_confirmation_flag IN ('Y','N')),
customer_statement_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_cust_stat_email_flag CHECK (customer_statement_email_flag IN ('Y','N')),
payment_receipt_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_pay_receipt_email_flag CHECK (payment_receipt_email_flag IN ('Y','N')),
tkt_charges_invoice_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_tkt_chg_inv_email_flag CHECK (tkt_charges_invoice_email_flag IN ('Y','N')),
pc_contract_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_pc_contract_email_flag CHECK (pc_contract_email_flag IN ('Y','N')),
sc_contract_email_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_sc_contract_email_flag CHECK (sc_contract_email_flag IN ('Y','N')),
frontier_contact_flag char(1) DEFAULT 'N' not null CONSTRAINT ckc_cp_frontier_contact_flag CHECK (frontier_contact_flag IN ('Y','N')),
CONSTRAINT pk_contact_person PRIMARY KEY (name_and_address_id,
contact_person_id) using index tablespace smartsoft_index
) ORGANIZATION HEAP tablespace smartsoft_data /