Skip to content
Advertisement

Merge statement giving error on oracle when trying to merge two tables

i have a student table as :

enter image description here

I have a stud_claim table as is :

enter image description here

student_id is the foreign key of student table.

At stud_claim table, I have paid_date column .paid_date has some data and some row is null.I need to update stu_claim table where paid_date is null and put the value of the service_date in that paid_date,if paid_date is null.To update the paid_date,the another condition for them is to match the id of the student and stud_claim of stud_claim table.

I tried using merge statement but its not working:

Or simply using update statement also ,it is also possible or not?

I got error at:

I tried from sql also as:

Advertisement

Answer

Simple update statement will be enough for it. There is issue in your update statement.(you are selecting id instead of service_date)

In merge statement, you can not update the column which are used in on clause so you can achieve it using WHERE clause as following:

Cheers!!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement