I do not want to use cursors for performance reasons.
Input Parameters for stored procedure: arg1, arg2,arg3 & arg4
For example:
Table A > A1 Column and A2 Column,
Table B > B1 Column (A.A1 <=>B.B1) foreign n primary key relation and B2 Column.
I want to update A.A2 value based on the following if condition,
if(arg1 == B.B2 && arg2 == B.B2)
{
Update A set A.A2 = 1 where A.A1 = arg4
}
else{
if(arg1 == 1 && arg3 == B.B2){
Update A set A.A2 = 0 where A.A1 = arg4
}
}
this is simple for one record but the Table A has 1000’s records that match A.A1 = arg4 so i have to apply the above logic or case for all records and want to avoid using cursors…how do i do it?
Try the below query.
Hope this Helps!!