I’m currently generating SQL insert statements from more than one tables, and in the generated data I need to use a CASE statement, like this:
select 'INSERT INTO TABLE1 (f1, f2, f3, f4 ...) values (' ||t.f1||',' ||CASE WHEN t.f2 > 0 THEN '1' ELSE '0' END CASE from table2 t , table3 t3
But at this point if I want to continue my statement with ... END CASE||','|| .... I can’t run the query anymore, as TOAD complains about not finding the FROM keyword.
A quick solution was to separate the ouput into fields, then save it to text, and edit, but there must be a better way.
Use END instead of END CASE