我尝试根据条件在存储过程中将值插入到我的表中:
alter procedure service_report_st2
as
insert into Service_report_step1(appointment_or_house)
select
case
when Service_report_step1.card_uid in(select card_uid from visits where vidpos_kod = 'A')
then '1'
when Service_report_step1.card_uid in(select card_uid from visits where vidpos_kod = 'B')
then '2'
else '3'
end
错误在于Service_report_step1.card_uid未找到,但这是表中的第一列Service_report_step1。appointment_or_house是第二列,如果visitstable 包含card_uidin ,则应包含“1”、“2”或“3” Service_report_step1。
我会很感激任何帮助!
简短的例子:
Visits表有 2 列: Card_uid 和 vidpos_kod
card_uid vidpos_kod
111-111 A
222-222 B
333-333 A
444-444 C
现在Service_report_step1表有card_uid(包含所有可能的卡片的列)和约会或房子列
card_uid appointment_or_house
111-111 1
222-222 2
333-333 1
444-444 1
因此,如果我的 in 与 in 相同card_uids,Service_report_step1我会根据in ( is '1', is '2')Visits确定列appointment_or_housevidpos_kodVisitsA, CB
我需要像示例一样正确插入Service_report_step1所有数据。