Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Formating Code in SQL Developer

Denes KubicekDec 6 2019 — edited Dec 7 2019

This is a small package that prints out a grid. The result I am getting by formating it via SQL Developer is quite strange. I am using the absolute standard. Version is 19.1:

pastedImage_0.png

CREATE OR REPLACE PACKAGE BODY "MATRIX_MANAGEMENT_UTIL_PKG" AS

c\_region\_start   VARCHAR2(4000) := '\<div class="t-Report-tableWrap"> ' || '\<table class="t-Report-report"> ' || '\<tbody>';

c\_region\_end     VARCHAR2(4000) := ' \</tbody> ' || '\</table> ' || '\</div> '; 

PROCEDURE print_table (

    p\_message OUT VARCHAR2

) IS

    v\_row                VARCHAR2(4000) := '\<tr>'; 

    v\_count\_col          NUMBER := 0;

    v\_count\_row          NUMBER := 0;

    v\_count\_cell         NUMBER := 0;

    v\_sum\_col\_id         NUMBER;

    v\_row\_limit\_failed   VARCHAR2(1) := 'N';

BEGIN

    htp.p(c\_region\_start); 

  /\*this is for horizontal header\*/

    FOR t\_col IN (

        SELECT

            id,

            name,

            CASE

                WHEN name IS NOT NULL THEN

                    '#80808075'

                ELSE

                    NULL

            END background,

            type

        FROM

            t\_matrix\_columns b

        ORDER BY

            id

    ) 

  /\*this order by is very important !!! \*/ LOOP

        v\_count\_col := v\_count\_col + 1;

        IF t\_col.type IS NOT NULL THEN

            v\_sum\_col\_id := t\_col.id;

        END IF;

        v\_row := v\_row || '\<td ' || ' class="t-Report-colHead" id="' || t\_col.id || '" align="center" style="background-color:'

        || t\_col.background || '"' || ' headers="SUBSTANZ"> ' || t\_col.name || '\</td>';

    END LOOP;

    v\_row := v\_row || '\</tr>\<tr cotoi>'; 

  /\*end of horizontal header\*/

    FOR t\_row IN (

        SELECT

            id,

            name,

            limit

        FROM

            t\_matrix\_rows

        ORDER BY

            id ASC

    ) LOOP

        v\_count\_row := v\_count\_row + 1;

        v\_row := v\_row || '\<td class="t-Report-cell" style="font-weight:bold !important" ' || 'align="center" id="' || TO\_CHAR

        (t\_row.id) || '">\<div style="width:110px; ' || 'display:block; white-space:pre-wrap;height:32px">' || t\_row.name || '\</br> (Limit: '

        || TO\_CHAR(t\_row.limit, 'FM999G999G999G999G990D00') || ')' || '\</div>\</td>';

        htp.p(v\_row);

        v\_row := NULL;

        FOR t\_cell 

     /\*this loop goes right - behaelter\*/ IN (

            SELECT

                id,

                value,

                col\_id

            FROM

                t\_matrix\_management

            WHERE

                row\_id = t\_row.id

            ORDER BY

                col\_id

        ) LOOP

            v\_count\_cell := v\_count\_cell + 1;

            IF t\_row.limit \< to\_number(t\_cell.value, 'FM999G999G999G999G990D00') AND t\_cell.col\_id = v\_sum\_col\_id THEN

                v\_row\_limit\_failed := 'Y';

            END IF;

            v\_row := v\_row || '\<td ' || ' class="t-Report-cell" id="SUBMAN" align="right"' || ' headers="' || TO\_CHAR(t\_row.

            id) || '">' || apex\_item.text(p\_idx => 1, p\_value => t\_cell.value, p\_size => 10, p\_maxlength => 20, p\_attributes

            => 'class="t-Report-cell" data-row-id="' || t\_row.id || '" data-id="' || t\_cell.id || '" data-sum-col-id = "' ||

            v\_sum\_col\_id ||

                CASE

                    WHEN t\_cell.col\_id != v\_sum\_col\_id THEN

                        '" onchange="setVal(this);"'

                    ELSE

                        '" disabled="disabled"'

                END

||

                CASE

                    WHEN v\_row\_limit\_failed = 'Y' THEN

                        'style ="background-color:#ffcccb;text-decoration: line-through;text-align:right"'

                    ELSE

                        'style ="text-align:right"'

                END, p\_item\_id =>

                CASE

                    WHEN t\_cell.col\_id != v\_sum\_col\_id THEN

                        'CELL' || t\_row.id || t\_cell.col\_id

                    ELSE

                        'SUM' || t\_row.id

                END

            );

            htp.p(v\_row);

            v\_row := NULL;

        END LOOP;

        v\_row := v\_row || '\</tr>';

        htp.p(v\_row);

        v\_count\_cell := 0;

        v\_row\_limit\_failed := 'N';

    END LOOP;

    htp.p(c\_region\_end);

EXCEPTION

    WHEN OTHERS THEN

        p\_message := 'Error : ' || sqlerrm || ' / ' || dbms\_utility.format\_error\_backtrace;

        htp.p('Error : ' || sqlerrm || ' / ' || dbms\_utility.format\_error\_backtrace);

END print\_table;

END matrix_management_util_pkg;

This post has been answered by Vadim Tropashko-Oracle on Dec 6 2019
Jump to Answer
Comments
Post Details
Added on Dec 6 2019
6 comments
679 views