2013-03-20 64 views
-1

任何人都可以向我解釋爲什麼當我運行以下內容時出現00904錯誤 我需要插入tabel 100行,我不知道爲什麼錯誤ORA-00904:「DWH_ITEM_SEQ」。「NEXTAVL」:無效的標識符

drop table DWH_ITEM_DIM; 
CREATE TABLE DWH_ITEM_DIM(
ITEM_ID NUMBER NOT NULL, 
ITEM_NAME VARCHAR2(5) NOT NULL, 
ITEM_TYPE VARCHAR2(1) NOT NULL, 
ITEM_COST NUMBER(10,2) NOT NULL, 
ITEM_PRICE NUMBER(10,2) NOT NULL, 
ITEM_FOR_SALE VARCHAR2(1) NOT NULL, 
CONSTRAINT ITEM_ID_PK PRIMARY KEY (ITEM_ID)); 

    DROP SEQUENCE DWH_ITE_SEQ; 
CREATE SEQUENCE DWH_ITE_SEQ 
START WITH 1 
INCREMENT BY 1 
NOCACHE 
NOCYCLE; 

TRUNCATE TABLE DWH_ITEM_DIM; 
INSERT INTO DWH_ITEM_DIM 
SELECT DWH_ITE_SEQ.NEXTAVL AS ITEM_ID, 
DBMS_RANDOM.STRING('U',5) AS ITEM_NAME, 
DBMS_RANDOM.STRING('U',1) AS ITEM_TYPE, 
ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_COST, 
ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_PRICE, 
DBMS_RANDOM.STRING('U',1) AS ITEM_FOR_SALE 
FROM DUAL 
CONNECT BY LEVEL <= 100; 
COMMIT; 

當我運行這個 '腳本輸出' 是:

table DWH_ITEM_DIM dropped. 
table DWH_ITEM_DIM created. 
sequence DWH_ITE_SEQ dropped. 
sequence DWH_ITE_SEQ created. 
table DM.DWH_ITEM_DIM truncated. 

Error starting at line 19 in command: 
INSERT INTO DM.DWH_ITEM_DIM 
SELECT DWH_ITE_SEQ.NEXTAVL AS ITEM_ID, 
DBMS_RANDOM.STRING('U',5) AS ITEM_NAME, 
DBMS_RANDOM.STRING('U',1) AS ITEM_TYPE, 
ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_COST, 
ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_PRICE, 
DBMS_RANDOM.STRING('U',1) AS ITEM_FOR_SALE 
FROM DUAL 
CONNECT BY LEVEL <= 100 
Error at Command Line:20 Column:8 
Error report: 
SQL Error: ORA-00904: "DWH_ITE_SEQ"."NEXTAVL": invalid identifier 
00904. 00000 - "%s: invalid identifier" 
*Cause:  
*Action: 
commited. 

我不無爲什麼?請幫助我我是新來的oracle

回答

3

這是一個錯字,更改NEXTAVLNEXTVAL