Answer the question
In order to leave comments, you need to log in
How to write a selection to an Oracle temporary array?
In general, the essence is this.
I have a table with order number, customer number, status and amount.
I select with the cursor all orders for which there was a refusal.
Then, through a cycle, I sort through them and do additional. conditions via if.
Depending on the amount, I will put a note in the client table. If less than 1000 - "ok", from 1000 to 5000 - "attention", if more than 5000 - "akhtung".
Plus, I do a heavy calculation of analytics for other parameters.
There was a need, if an order with an amount higher than "5000" was caught, then other orders of this client should not be processed in order to reduce the request execution time.
For this I want some temporary "array" or "table",
But actually I do not know how to implement this "array".
In code it's like this:
DECLARE
type arr_table is TABLE of NUMBER;
arrItem arr_table;
BEGIN
FOR ord IN (SELECT
OrderNum,
OrderSum,
OrderClient
FROM Orders
WHERE status = 'Otkaz') LOOP
-- этот IF хочу обернуть во что-то вроде -- IF (ord.OrderNum Not in arrItem) THEN
-- что бы не обрабатывать остальные договора клиента
IF (ord.OrderSum > 5000)
THEN
-- этот вариант не подходит, т.к. перезатирается массив
SELECT OrderNum BULK COLLECT INTO arrItem FROM Orders WHERE OrderClient = ord.OrderClient
-- этот вариант не работает т.к. не понимает что такое arrItem
-- INSERT /*+append*/ INTO arrItem SELECT ncdaagrid FROM cda WHERE icdaclient = crAgr.icd1client;
ELSIF (ord.OrderSum > 1000) AND (ord.OrderSum < 5000)
THEN
--- тут функции разного рода подсчетов и аналитики.
END IF;
END LOOP;
END;
Answer the question
In order to leave comments, you need to log in
Create an associative array and write the IDs of Achtung clients into it as indexes. In the loop, before processing the next order, check if there is an element in the array of ahtungs with an index equal to the customer id.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question