I went through some of the already answered questions, mentioned below, but could not find a solution that worked for me.
ORA-14551: cannot perform a DML operation inside a query
ORA-14551: cannot perform a DML operation inside a query error while using Execute immediate
I have written this within a function, that I am calling from a procedure.
OPEN c_rules_details;
LOOP
FETCH c_rules_details INTO rule_conditions_record;
EXIT WHEN c_rules_details %notfound;
dbms_output.put_line('Range and rule is '|| rule_conditions_record.rdr_tmplt_id || rule_conditions_record.rdr_rng_from ||rule_conditions_record.rdr_rng_to);
SELECT COUNT(*) INTO v_balance_records FROM t_scb_temp_objects WHERE RULE_CONDITION=rule_conditions_record.rdr_tmplt_id AND CHARGE is NULL;
dbms_output.put_line('Number of records in rule are '|| v_balance_records);
IF v_balance_records>rule_conditions_record.rdr_rng_from AND v_balance_records<rule_conditions_record.rdr_rng_to THEN
v_ssql_stmnt:='UPDATE t_scb_temp_objects
SET CHARGE='||rule_conditions_record.rfr_chrg_amt||' WHERE RULE_CONDITION='||rule_conditions_record.rdr_tmplt_id;
EXECUTE IMMEDIATE v_ssql_stmnt;
END IF;
END LOOP;
CLOSE c_rules_details;