Page 1 of 1

Batch spliting wrong formatted if statements

Posted: 09 Nov 2017 02:06
by bufoss
Hi all,
I have a folder with .sql files.

Inside the scripts there are well formatted and not well formatted "if statements"

To be more specific there are if statements which are all in the same line.
.i.e.

Code: Select all

IF  CONDITION  THEN  STATEMENT1; END IF;    

(the stament can be also in lower case)

Could you help me to make a batch modifying the above case
to

Code: Select all

IF  CONDITION  THEN  
  STATEMENT1; 
END IF;

Code: Select all

@echo off&cls

setlocal enabledelayedexpansion

echo. Checking files ... Do not close until end

for %%a in (*.sql) do (
   ........
)
echo. Finished

pause


Thank you

--------------
Real case :
IF NOT CUR1%ISOPEN THEN RETURN; END IF;
iF v_a + v_b < 5 then find_min ; end If;

Re: Batch spliting wrong formatted if statements

Posted: 09 Nov 2017 02:36
by penpen
You might use Dave's "JREPL.BAT" to insert a line-ending ("\r\n" in c-style) after "THEN" and before "END IF;":
http://www.dostips.com/forum/viewtopic.php?f=3&t=6044.

penpen