Logo SQLinForm

 

[started] Linebreak / alignment options?

[started] Linebreak / alignment options?
March 20, 2012 04:28PM
Hi,

I wonder if it is possible to also enable line-breaks / alignment for these two cases:

1) align comma-separated parameters in function calls, like for instance in this fragment:

...
FROM  (SELECT  nnp1.rowid                                                               rowid1
              , nnp2.rowid                                                              rowid2
       FROM     xwga_vrw_nnp nnp1
       JOIN     xwga_vrw_nnp nnp2
       ON       nnp1.ber_id                                         = nnp2.ber_id
       AND      nnp2.verw_id                                        > nnp1.verw_id
       AND      NVL(nnp1.new_failsurs_datb, nnp1.old_failsurs_datb) = NVL
                (nnp2.new_failsurs_datb, nnp2.old_failsurs_datb)
       WHERE    nnp1.verwerken                                                = 'J'
       AND      nnp1.time_processed                                     IS NULL
       AND      NVL(nnp1.new_failsurs_datb, nnp1.old_failsurs_datb) IS NOT NULL
       AND      nnp2.verwerken                                                = 'J'
       AND      nnp2.time_processed                                     IS NULL
       AND      NVL(nnp2.new_failsurs_datb, nnp2.old_failsurs_datb) IS NOT NULL
       ORDER BY nnp1.verw_id
              , nnp2.verw_id)
WHERE  rownum = 1;

-- ontdubbel FSS
p_ontdubbel_nnp(p_batch_id, f_bepaal_nnp_rij(rowid1), f_bepaal_nnp_rij(rowid2), 'FSS');


so that that would be something like this:


...
FROM  (SELECT   nnp1.rowid                      rowid1
              , nnp2.rowid                      rowid2
       FROM     xwga_vrw_nnp nnp1
       JOIN     xwga_vrw_nnp nnp2
       ON       nnp1.ber_id                   = nnp2.ber_id
       AND      nnp2.verw_id                  > nnp1.verw_id
       AND      NVL(nnp1.new_failsurs_datb
                  , nnp1.old_failsurs_datb) 
              = NVL(nnp2.new_failsurs_datb
                  , nnp2.old_failsurs_datb)
       WHERE    nnp1.verwerken                = 'J'
       AND      nnp1.time_processed               IS NULL
       AND      NVL(nnp1.new_failsurs_datb
                  , nnp1.old_failsurs_datb)   IS NOT NULL
       AND      nnp2.verwerken                = 'J'
       AND      nnp2.time_processed               IS NULL
       AND      NVL(nnp2.new_failsurs_datb
                  , nnp2.old_failsurs_datb)   IS NOT NULL
       ORDER BY nnp1.verw_id
              , nnp2.verw_id)
WHERE  rownum = 1;

-- ontdubbel FSS
p_ontdubbel_nnp(p_batch_id
              , f_bepaal_nnp_rij(rowid1)
              , f_bepaal_nnp_rij(rowid2)
              , 'FSS');

Which makes to overall length of the code a bit longer but more readable in my opinion; long lines are harder to follow with your eyes.

or 2) before the THEN in IF-THEN-ELSE conditions or CASE statements (there's an option to insert a break for the THEN keyword in CASE statements, but it does not seem to do anything?)
This is what I can get now:

CASE
WHEN r_signal.RT_NM_WORD = 'NI' THEN
   v_knight_id              := f_figure_out(r_signal.castle_id, p_batch_words) ;
WHEN r_signal.RT_NM_WORD = 'IT' THEN
   v_knight_id              := f_figure_out(r_signal.swamp_id, p_batch_words) ;
END CASE;

IF(p_rule_id = 1452) THEN
   engage_warp_drive('bicycle')
END IF;


and this is what I'd like to get:


CASE
WHEN r_signal.RT_NM_WORD = 'NI' 
THEN v_knight_id := f_figure_out(r_signal.castle_id
                               , p_batch_words) ;
WHEN r_signal.RT_NM_WORD = 'IT' 
THEN v_knight_id := f_figure_out(r_signal.swamp_id
                               , p_batch_words) ;
END CASE;

   
IF(p_rule_id = 1452) 
THEN
   engage_warp_drive('hamster')
END IF;



Edited 3 time(s). Last edit at 03/29/2012 10:35PM by guidomarcel.
Re: Linebreak / alignment options?
March 29, 2012 06:18PM
Hi LĂșthien,
many thanks for your feedback. I can see the reason for your suggestion but I do not know (yet) how to implement it, because there might be many functions which do not want/need a linebreal after/before a comma. Other function might need a line break. I can not see a general rule for this option. Do you have any idea?

Regards
Guido
Author:

Your Email (Optional):


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 17 plus 12?
Message: