Hi I have a SQL file i wanted to remove case statements which are present in a single line as well as case statements which are present in multiple lines. For example, my input file is:
Select a,
b,
c,
CASE when e in (1,0,2) then Y END as e
f,
g,
h,
CASE when i in (5,
6,
7,
9.
,10) then N
END as i
FROM ABCD
In my output it should be
Select a,
b,
c,
e as e
f,
g,
h,
i as i
FROM ABCD
I'm using the sed command
sed -i 's/\bCASE\b.*\bEND\b/${FIELD}/' $FILE
but this is working only for case and end statement which are on single line I want to make it work for case and end statements which are multiple lines too.
perl
:perl -0777 -pe 's/case when (\w+) in.*?end as /$1 as /gis'