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!

How do I make the comma seperated values into seperate rows. Ive posted all the required data below.

User_051LONov 9 2022 — edited Nov 9 2022

Create a table with below columns,

table name: users
User_id
Request_id

Create a procedure for inserting data into the above table, the input will be pi_user_id, pi_request_id for the proc and the format of the input parameters will be as below,

pi_user_id = 111;

pi_request_id = '10,20,30,40';

pi_request_id will be passed as comma seperated values from UI. You have to split it and store each value as single row into the table.
After inserting, if I query the table, it should be as below,

User_id  Request_id

111              10

111              20

111              30

111              40

I have created the table and Procedure. Updating the proc below

CREATE OR REPLACE procedure insertusers(

p_user_id IN USERS.USER_ID%TYPE

p_request_id IN USERS.REQUEST_ID%TYPE)

IS

BEGIN

INSERT INTO users ("USER_ID", "REQUEST_ID")

VALUES (p_user_id, p_request_id);

COMMIT;

END;

So I should add the condition to make the comma separated values into each individual row as shown above. Please help me with this question? Thank you..

This post has been answered by mathguy on Nov 10 2022
Jump to Answer
Comments
Post Details
Added on Nov 9 2022
10 comments
155 views