Frage

In a procedure, I need to decide about the value of a column using many if-else conditions. The script starts with a

FOR rec IN (SELECT....) LOOP Begin

and decides on many different values the rec sub-records can obtain in each iteration. for some cases, there might be just 2 or 3 variable assignments and some cases include running a separate procedure or doing an INSERT operation.

Does this approach the best approach for decision making from the aspect of performance where there are many records as the result of loop's SELECT statement, or there might be better alternatives? What if I adapt Chain-of-responsibility pattern in writing this procedure? Will this approach increase performance or just makes things even worse?

Regards.

War es hilfreich?

Lösung

If possible stay inside SQL. For bigger volumes, avoid "if" as you will be serialized on your PL/SQL side. Have it better as CASE inside your SELECT if possible. For example, in case of SQL paralelization it can be handled by multiple processes for different rows at the same time.

Hope it helps, Igor

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top