Hello! Technical task: - Read the records on each order in the procedure from the table of orders. - Run through each order. And compare the final cost with the actual cost of each product.

How can I save a lot of records returned by the select and then operate on each of them in a loop? Even if you can implement it more efficiently (without reading and saving), you still want to know how you can save several sample records and then use them?

  • Show what you tried to do. - Vladimir Glinskikh 1:58 pm
  • one
    I wonder who is trying to close the question, the question is absolutely justified. Especially from the point of view of Oracle, in which there are ready-made tools for storing sets. And at the same time, these tools are unique among relational bases - Mike

1 answer 1

To perform such a task, you need to create a collection-type procedure with fields corresponding to the table (the simplest thing is to use Tablename% ROWTYPE). Declare a variable of this type. And select the required entries with the BULK COLLECT INTO construct.

 PROCEDURE process_all_rows IS TYPE table_type IS TABLE OF MyTable%ROWTYPE INDEX BY PLS_INTEGER; rows table_type; BEGIN SELECT * BULK COLLECT INTO rows FROM MyTable; FOR indx IN 1 .. rows.COUNT LOOP ... Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌ Π² опСрациях поля Π²ΠΈΠ΄Π° rows(indx).имя_ΠΊΠΎΠ»ΠΎΠ½ΠΊΠΈ END LOOP; END process_all_rows;