Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Multiple subquery in update or two queries (PL/SQL) ?
Hello all.
I have to do the following update:
UPDATE MEASURES
SET ORDER_ID = :p_new_order_id,
ORDER_SORT = ORDER_SORT - (select ORDER_SORT FROM MEASURES
WHERE ID = :p_new_starting_measure)WHERE ORDER_ID = :p_order_id
WHERE ID = :p_new_starting_measure);
As you can see, this update uses the same subquery two times. My question is both in principle and for this specific case: Would it make more sense to do it like above, or could there be valid cases where I might want to run the single-value-select query first in PL/SQL and then use it's result as a variable in the query? (Of course, if I split up the statement in two, then I may run into data integrity issues, right?)
thanks!
best,
Martin
Received on Wed Jul 12 2006 - 07:01:01 CDT