ora-02287不允许序列号

时间:2015-11-08 16:41:11

标签: sql oracle oracle10g

我正在尝试运行以下查询以使用正确的值填充表。我已经单独运行了select语句,没有price_s和created_by,creation_date,last_updated_by和last_update_date,它提取了我需要的所有内容。当我添加这些值时,它会给出错误,我已经通过了其中的一些,但是我被困在这个ORA-02287: Sequence number not allowed here上,我到处寻找并找不到我做错了什么。这可能是一些简单的答案,但我现在看不到它。 这是代码:

CREATE SEQUENCE price_s START WITH 1001;

INSERT INTO price (price_id, item_id, price_type, active_flag, start_date, end_date, amount, created_by, creation_date, last_updated_by, last_update_date)
SELECT price_s.nextval, i.item_id,
active_flag,
cl.common_lookup_id,TRUNC (i.release_date),
CASE
WHEN (TRUNC (SYSDATE) - TRUNC (i.release_date)) < 31 AND active_flag = 'N' THEN NULL
WHEN (TRUNC (SYSDATE) - TRUNC (i.release_date)) > 30 AND active_flag = 'N' THEN TRUNC (i.release_date) + 30
END AS END_DATE,
CASE
WHEN (TRUNC (SYSDATE) - TRUNC (i.release_date)) < 31 AND active_flag = 'Y' THEN
CASE
WHEN rental_days = 1 THEN '3'
WHEN rental_days = 3 THEN '10'
WHEN rental_days = 5 THEN '15'
END
WHEN (TRUNC (SYSDATE) - TRUNC (i.release_date)) > 30 AND active_flag = 'N' THEN
CASE
WHEN rental_days = 1 THEN '3'
WHEN rental_days = 3 THEN '10'
WHEN rental_days = 5 THEN '15'
END
WHEN (TRUNC (SYSDATE) - TRUNC (i.release_date)) > 30 AND active_flag = 'Y' THEN
CASE
WHEN rental_days = 1 THEN '1'
WHEN rental_days = 3 THEN '3'
WHEN rental_days = 5 THEN '5'
END
END AS AMOUNT,
1,SYSDATE,1,SYSDATE
FROM     item i CROSS JOIN
    (SELECT 'Y' AS active_flag FROM dual
     UNION ALL
     SELECT 'N' AS active_flag FROM dual) af CROSS JOIN
    (SELECT '1' AS rental_days FROM dual
     UNION ALL
     SELECT '3' AS rental_days FROM dual
     UNION ALL
     SELECT '5' AS rental_days FROM dual) dr INNER JOIN
     common_lookup cl ON dr.rental_days = SUBSTR(cl.common_lookup_type,1,1)
WHERE NOT ((TRUNC (SYSDATE) - TRUNC (i.release_date)) <= 31 AND active_flag = 'N')
AND NOT cl.common_lookup_table = 'RENTAL_ITEM'
ORDER BY 1, 2, 3;

关于我做错的任何想法?

1 个答案:

答案 0 :(得分:2)

我弄清楚我的陈述有什么问题。我知道这很简单,我当时看不到它。我忘了带走了 ORDER BY 1, 2, 3;它弄乱了一切,抱歉占用了任何人的时间。