试图获得以下伪代码之类的东西与PL/SQL开发人员一起工作,但没有任何运气。想象一下我有一个带有A-E列的桌子。
Declare
name varchar(100);
address varchar(100);
Begin
If column a = 'Y'
name = column b;
address = column c;
else
name = column d;
name = column e;
End
任何帮助将不胜感激!
我看不出需要PL/SQL,平原SQL也会做得同样
select case
when column_a = 'Y' then colum_b
else colum_d
end as name,
case
when column_a = 'Y then colum_d
else column_e
end as address
from the_table;
封装在视图中可能是一个好主意
尝试
Select
case when columnA = 'Y' then columnB else columnD end into name,
case when columnA = 'Y' then columnD else columnE end into address
From Table