INSERT INTO sales_ordering VALUES (1, 10, 'Anna',   2, 100);  -- OK
INSERT INTO sales_ordering VALUES (2, 11, 'Narek',  0,  50);  -- will fail in consumer (division by zero)
INSERT INTO sales_ordering VALUES (3, 12, 'Mariam', -1, 30);  -- will fail in consumer (qty>0 rule)
COMMIT;

SELECT
  *
FROM sales_qtab
ORDER BY enqueue_time;

SELECT * FROM sales_ordering ORDER BY orderid;
BEGIN
  FOR i IN 1..30 LOOP
    consume_sales;
  END LOOP;
END;

SELECT name, queue_type
FROM user_queues
WHERE queue_table = 'SALES_QTAB'
ORDER BY queue_type;

SELECT *

FROM sales_qtab
WHERE state = 'EXPIRED'
ORDER BY enqueue_time;
