0

I have the input

var1,var2,var3

and I need to insert or update into 3 row table with split by ",", How do I do that, thank you

1

1 Answer 1

2

If i understood your question correctly you want to create three rows out of one input text line broken down by some delimitter. You can do this with Regex_substr

CREATE TABLE TEST AS ( 
SELECT REGEXP_SUBSTR ('var1,var2,var3','[^,]+',1 ,LEVEL) values 
FROM DUAL 
CONNECT BY REGEXP_SUBSTR ('var1,var2,var3','[^,]+' ,1 ,LEVEL) IS NOT NULL)

and just the insert as follow up:

INSERT INTO TEST (
SELECT REGEXP_SUBSTR ('var1,var2,var3', '[^,]+',1,LEVEL) VALUES
FROM DUAL
CONNECT BY REGEXP_SUBSTR ('var1,var2,var3','[^,]+' ,1 ,LEVEL) IS NOT NULL)

For the update you need to be more specific on what the operation (before -> after) shall accomplish

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.