Skip to Main Content

SQL & PL/SQL

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!

auto count generate - Sql

user10991018Feb 24 2020 — edited Feb 25 2020

Hi i have a requirement in one of my apex applicaiton.

DECLARE

    CURSOR cur_emp IS

    SELECT

        regexp_substr(e_objective_description, '[0-9]*\.[0-9]*')

        || ''

        || ROW_NUMBER() OVER(

            PARTITION BY obj.brch_spec_obj_id

            ORDER BY

                brch_workplan_id

        ) AS keycnt,

        brch_workplan_id

    FROM

        wpa_brch_specific_obj_table   obj,

        wpa_annual_brch_wp_table      brch

    WHERE

        AND obj.brch_spec_obj_id = brch.brch_spec_obj_id

        AND brch.logical_delete_ind = 'N';

    cur_emp1 cur_emp%rowtype;

BEGIN

    OPEN cur_emp;

    LOOP

        FETCH cur_emp INTO cur_emp1;

        EXIT WHEN cur_emp%notfound;

        UPDATE wpa_annual_brch_wp_table

        SET

            key_strategy = TRIM(cur_emp1.keycnt

                                || ' '

                                || ltrim(regexp_replace(key_strategy, '[0-9]*', ''), '.'))

        WHERE

            brch_workplan_id = cur_emp1.brch_workplan_id

            AND wpa_annual_brch_wp_table.logical_delete_ind = 'N';

    END LOOP;

    CLOSE cur_emp;

END;

this event fires on page load.

my problem is every time when i insert a new record my count is coming correct but

every time it is adding extra space.

it should add only first time

eg.

first time

1.1 Test1

when i load page again it will show as. every time it is adding up one more space to the existing one.

1.1  Test

1.1   Test

also when i am entering the 9-1-1 branch information the numbers are getting disppeared.and just showing - -

can you please advise.

thanks.

Comments
Post Details
Added on Feb 24 2020
11 comments
444 views