在这个澄清之后
假设我们有一个程序,我们在变量 p_user_in 中获取用户条目,并在参数 p_val 中获取所需值。
我猜你也在为过程提供主键值(我将一列 col1 作为表的主键)并且我们在 p_prim_val 中获得了这个值。
那么您可以使用以下更新语句来相应地更新您的表 -
update table_name
set January = case when p_user_in = 1 then p_val else January end,
February = case when p_user_in = 2 then p_val else February end,
March = case when p_user_in = 3 then p_val else March end,
April = case when p_user_in = 4 then p_val else April end,
May = case when p_user_in = 5 then p_val else May end,
June = case when p_user_in = 6 then p_val else June end,
July = case when p_user_in = 7 then p_val else July end,
August = case when p_user_in = 8 then p_val else August end,
September = case when p_user_in = 9 then p_val else September end,
October = case when p_user_in = 10 then p_val else October end,
November = case when p_user_in = 11 then p_val else November end,
December = case when p_user_in = 12 then p_val else December end
where col1 = p_prim_val