In going through reams of PL/SQL code it dawned on me that procedural language is often formatted differently than structured query language in the same code sample. I decided to take a shot at formatting procedural language code like SQL and I like the result.
declare var1 number(9) := 0; var2 number(9) := 0; var3 number(9) := 0; var4 number(9) := 0; var5 number(9) := 0; var6 number(9) := 0; var7 number(9) := 0; var8 number(9) := 0; var9 number(9) := 0; begin if var1 = var2 and var3 = var4 or var5 = var6 then while var1 < var9 and var2 is null or var4 is not null loop select a.col1 into var6 from table1 a , table2 b where a.col1 = b.col1 and a.col2 = var7 or b.col2 = var8; var1 := var1 + 1 end loop; elseif var1 = var2 and var1 <> var3 or var1 <> var4 then insert into table3 ( col1 , col2 , col3 ) values ( var1 , var2 , var3 ); else var9 := 100; if var4 is not null then var8 := 100; endif; endif; end
Note that I am using ten character tabs throughout the code and formatting and aligning as I would with SQL. I find the conditional structures in the IF and WHILE statements much clearer this way.
*Footnote: I recently used the TOAD formatter command and have found it surpasses my own standard for formatting. If you have TOAD I highly recommend the use of the formatter for all code. The saving in effort for the maintenance people that follow in your development footsteps is well worth it.