1

Topic: Using the cursor based on the list of sellers, at which total of real sales

I have a task: Using the cursor based on the list of sellers, at which total of real sales (the total under all orders) does not coincide with  the total (field RESULT in table SELLERS) to produce the coordination of field value RESULT and the totals of sales. To deduce the list of sellers on which changes with total instructions on which adjustment has been led have been produced. To create the procedure fulfilling automatic adjustment  of the total.
I wrote the code, but something does not change field RESULT, in what an error?
CREATE OR REPLACE PROCEDURE fy IS
CURSOR sss IS
SELECT id, result FROM sellers WHERE result! = (SELECT SUM (Total_sum) FROM orders WHERE seller_id=sellers.id);
n NUMBER;
BEGIN
FOR s IN sss LOOP
SELECT SUM (Total_sum) INTO n FROM orders WHERE seller_id=s.id;
UPDATE sellers SET result = n WHERE id=s.id;
END LOOP;
END;
/
DECLARE
CURSOR sss IS
SELECT id, result FROM sellers WHERE result! = (SELECT SUM (Total_sum) FROM orders
WHERE seller_id=sellers.id);
n NUMBER;
BEGIN
FOR s IN sss LOOP
SELECT SUM (Total_sum) INTO n FROM orders WHERE seller_id=s.id;
UPDATE sellers SET result = n WHERE id=s.id;
END LOOP;
END;
/
ROLLBACK;

2

Re: Using the cursor based on the list of sellers, at which total of real sales

Syntactic error in operator COMMIT

3

Re: Using the cursor based on the list of sellers, at which total of real sales

Gomn wrote:

in what an error?

4

Re: Using the cursor based on the list of sellers, at which total of real sales

Gomn wrote:

CREATE OR REPLACE PROCEDURE fy IS
CURSOR sss IS
SELECT id, result FROM sellers WHERE result! = (SELECT SUM (Total_sum) FROM orders WHERE seller_id=sellers.id);
n NUMBER;
BEGIN
FOR s IN sss LOOP
SELECT SUM (Total_sum) INTO n FROM orders WHERE seller_id=s.id;
UPDATE sellers SET result = n WHERE id=s.id;
END LOOP;
END;
/
DECLARE
CURSOR sss IS
SELECT id, result FROM sellers WHERE result! = (SELECT SUM (Total_sum) FROM orders
WHERE seller_id=sellers.id);
n NUMBER;
BEGIN
FOR s IN sss LOOP
SELECT SUM (Total_sum) INTO n FROM orders WHERE seller_id=s.id;
UPDATE sellers SET result = n WHERE id=s.id;
END LOOP;
END;
/
==> ROLLBACK;

Esteem about ACID and transactions as a whole.
0, well he at least tries to write something itself. It is already much better than anything.

5

Re: Using the cursor based on the list of sellers, at which total of real sales

env wrote:

would try to write something itself

* Interposes on a forum someone's code smile))