The problem is, that many poster don't know, how to format sourcecodes. Example:
/*
|| Selecting the sum from all sub-order's
*/
if :control.sub_order_id is not null then
select sum (value)
into :control.sum
from sum_orders
where order_id in (select order_id
from sub_orders
where sub_order_id = :control.sub_order_id
and sub_order_type = 'ONLINE');
else
:control.sum := 0;
end if;
/*
|| now we use the sum in the ...
*/
Who can read that? I love puzzling, but not in sourcecodes. How can we solve this problem?
Use [pre] before your sourcecode and [/pre] after the sourcecode. Then it is readable like your original code:
[pre]
...
if :control.sub_order_id is not null then
select sum (value)
into :control.sum
...
[/pre]
and here is the solution of the above example after using the preformat-tags:
/*
|| Selecting the sum from all sub-order's
*/
if :control.sub_order_id is not null then
select sum (value)
into :control.sum
from sum_orders
where order_id in (select order_id
from sub_orders
where sub_order_id = :control.sub_order_id
and sub_order_type = 'ONLINE');
else
:control.sum := 0;
end if;
/*
|| now we use the sum in the ...
*/
This is readable code at it's best!
Try it
Gerd
I usually prefer [code] for pl/sql-blocks because this tag preserves blank lines.
ReplyDeleteA button, like the ones for bold, underline and italic, would solve the problem.
ReplyDelete[pre] vs. [code] seems to be identical in the otn-forum. [pre] is the only documented way: http://www.oracle.com/technology/forums/faq.html#q14
ReplyDeleteI have always formated code in the manner suggest and do my best to influence junior programmers to do the same. This is the FIRST time in 25 years that I have EVER seen ANYONE other than me recommend this formatting style.
ReplyDeleteThis kind of formatting is one of the best readable formats I found in the last 16 years. So I use it :-)
ReplyDeleteAlso,like Jens,I prefer [code]. This tag preserves color for reserved words too.
ReplyDeleteHi Rosario,
ReplyDeletecan you post an example with color?