错误 ORA-06550 ORA-00933
我有一个销售表:
Name Null? Type
SALE_ID NOT NULL NUMBER(4)
SALE_DATE DATE
NO_OF_PRODS NUMBER(4)
PROD_ID NOT NULL NUMBER(4)
CUST_ID NOT NULL NUMBER(4)
DESP_ID NOT NULL NUMBER(4)
SALE_RECEIPT NOT NULL NUMBER(5)
我试图将随机生成的数据插入到销售表中。我正在使用 iSQL plus for oracle。这只是我必须创建的测试数据。 我运行以下脚本来生成数据:
begin
insert into sales
select sale_id_seq.nextval,
sysdate,
trunc(dbms_random.value(000,999)),
p.prod_id, c.cust_id
FROM dba_xy.product p, dba_xy.customer c,
desp_id_seq.nextval,
trunc(dbms_random.value(0000,9999));
end; /
但是当我这样做时,出现以下错误消息:
trunc(dbms_random.value(0000,9999));
*
ERROR at line 9: ORA-06550: 第 9 行,第 21 列: PL/SQL: ORA-00933: SQL 命令未正确结束 ORA-06550: 第 2 行,第 2 列: PL/SQL:SQL 语句被忽略。
我做错了什么?
我刚刚意识到 DESP_ID 是销售表中的外键,但目前发送表是空的,当我尝试将数据插入任一表时,我无法导致一个表需要另一个表中的数据。我最终收到此错误消息:
PL/SQL: ORA-02289: sequence does not exist
I have a sales table:
Name Null? Type
SALE_ID NOT NULL NUMBER(4)
SALE_DATE DATE
NO_OF_PRODS NUMBER(4)
PROD_ID NOT NULL NUMBER(4)
CUST_ID NOT NULL NUMBER(4)
DESP_ID NOT NULL NUMBER(4)
SALE_RECEIPT NOT NULL NUMBER(5)
I am trying to insert randomly generated data into the sales table. I am using iSQL plus for oracle. This is just test data that I have to create.
I run the following script to generate the data:
begin
insert into sales
select sale_id_seq.nextval,
sysdate,
trunc(dbms_random.value(000,999)),
p.prod_id, c.cust_id
FROM dba_xy.product p, dba_xy.customer c,
desp_id_seq.nextval,
trunc(dbms_random.value(0000,9999));
end;
/
But when I do, the following error message appears:
trunc(dbms_random.value(0000,9999));
*
ERROR at line 9:
ORA-06550: line 9, column 21:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 2, column 2:
PL/SQL: SQL Statement ignored.
What have I done wrong?
I just realised that the DESP_ID is a foreign key within the sales table, but currently the despatch table is empty and when I try to insert data into either tables, I'm not able to cause one table needs the data from the other table. I end up getting this error message:
PL/SQL: ORA-02289: sequence does not exist
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法选择 FROM
Try:
顺便说一句,您确定要在这里使用笛卡尔积吗?也许错过了某些连接?
You cannot select FROM
Try:
BTW, are you sure that you want an Cartesian product here, maybe some join is missed ?