Need your help in pl/sql.

by Vijay
(chandigadh)


I have a table having 6 column, and the 7th column I want to insert data depend upon the existed column. detail in excel attached.

Kindly help me.

Regards,

Vijay

Comments for Need your help in pl/sql.

Average Rating starstarstarstar

Click here to add your own comments

Oct 23, 2015
Rating
starstarstarstarstar
jack
by: Anonymous

I think your blog is exactly what I have been looking for;

Jun 23, 2015
Rating
starstarstarstarstar
Good post
by: Elwin Harvey

Awesome blog! How much time did you spend to make so wonderful site? Thank you!

Mar 26, 2015
Rating
star
need dynamic pl/sql
by: Anonymous

data will come in dynamic way so, I need pl/sql to update the table as per conditional requirement depend upon rest of the column

Mar 25, 2015
Rating
starstarstarstarstar
You may not need PL/SQL for this
by: Anonymous

You can do this in pure SQL - all you need is an update statement or possibly a series of update statements that sets the value of your 7th column dependant on the values of the other 6 columns.

If the function is very complicated, you might want to write a PL/SQL function to return the value of the 7th column like this:

UPDATE mytable
SET col_7=col7val(col1,col2,col3,col4,col5,col6);

Oherwise you could use the CASE clause or the DECODE function in SQL like this:

UPDATE mytable
SET col_7 =
CASE col1 WHEN col_1_case_1_val THEN
CASE col2 WHEN col_2_case_1_val THEN
CASE col3 WHEN col_3_case_1_val THEN
CASE col4 WHEN col_4_case_1_val THEN
CASE col5 WHEN col_5_case_1_val THEN
CASE col6 WHEN col_6_case_1_val THEN case_1_val_for_col_7 END
END
END
END
END
END;

In terms of performance it would probably be better to use just pure SQL but thi smay make the SQL very complex, in which case maintenance might be easier in PL/SQL.

Click here to add your own comments

Join in and write your own page! It's easy to do. How? Simply click here to return to Oracle Questions.