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!

Oracle PL/SQL Insert comma separated string split into rows with varying label values

VinipandaNov 13 2020 — edited Nov 13 2020

Hi,

I had a requirement in the existing thread :https://community.oracle.com/tech/developers/discussion/comment/16775085#Comment_16775085.
and this is fiddle for last thread solution tested : https://dbfiddle.uk/?rdbms=oracle_18&fiddle=412a6e27a22741ee1c31eee4a3f2bf3a
This was answered, however the requirement has changed and i have replicated the scenario here in fiddle.
In short, string is taken as input, split into rows and pushed into data. Earlier the labels against which it was pushed were constant, in terms of name and number. Now they shall vary,

Oracle 11g Release 2 | db<>fiddle (0 Bytes)
So, the table push_data_pivot has a new column, app_id.
On basis of app_id, there are label values. SO for app_id=1 there are 14 rows, with 14 labels. . For app_id=2, there are 10 labels.
So when string is passed in procedure with app_id, the string would be split using the same regex logic sequence wise, using the seq column.
Just like we were splitting from COL01....COL14, now we need to split from seq 1....10 or 1...14 as per app_id passed.
So earlier we were inserting the labels COL01..14 and the corresponding values.
Now we already have labels, so we need to match app_id, label seq and according push rows.
So if the procedure passes string with app_id=1, it would split the string accordingly in the 14(max) columns and so on.

I tried adding app_id and make changes in procedure but am not able to.
The proc would be executed for ids like this then:

BEGIN
PUSH_DATA_PIVOT_1(111,'[""Project title for IT Heads"","The values are,\n "exactly" up to the requirement and analysis done by the team.
Also it is difficult to,\n prepare a scenario notwithstanding the fact it is difficult. This user story is going to be slightly complex however it is up to the team","Active","Disabled","25 tonnes of fuel","www.examplesites.com/html.asp&net;","Apprehension","","","","25","Stable"]',1);
END;
/
BEGIN
PUSH_DATA_PIVOT_1(112,'[""Project title for IT Heads"","The values are,\n "exactly" up to the requirement and analysis done by the team.
Also it is difficult to,\n prepare a scenario notwithstanding the fact it is difficult. This user story is going to be slightly complex however it is up to the team","Active","Disabled","25 tonnes of fuel","www.examplesites.com/html.asp&net;","Apprehension"]',2);
END;
/
The old fiddle link is available in the old thread mentioned for reference.

This post has been answered by Frank Kulash on Nov 13 2020
Jump to Answer

Comments

Post Details

Added on Nov 13 2020
13 comments
2,005 views