简体   繁体   English

ORACLE SQL APEX 使用序列号给出缺少表达式错误

[英]ORACLE SQL APEX using sequence numbers gives an missing expression error

I created sequence for manager first.我首先为经理创建了序列。

CREATE SEQUENCE manager_seq
START WITH 200
MAXVALUE 299
CYCLE 
CACHE 10;

Then I inserted some values using .NEXTVAL然后我使用 .NEXTVAL 插入了一些值

INSERT INTO manager
VALUES (manager_seq.NEXTVAL,'')

When I try to query with where statement it says ORA-00936: missing expression当我尝试使用 where 语句查询时,它显示 ORA-00936: missing expression

select * from manager where number = 201;

Why it isn't working with sequnce numbers how can I use them?为什么它不适用于序列号我该如何使用它们?

Column name can't be number , that's a reserved word - reserved for datatype .列名不能是number ,这是一个保留字 - 为datatype保留。 For example:例如:

SQL> create table manager (id     number,
  2                        number number);       --> this
                      number number)
                      *
ERROR at line 2:
ORA-00904: : invalid identifier

Therefore, post table description (so that we could suggest what to do) or use valid query.因此,发布表描述(以便我们建议做什么)或使用有效查询。

If you use a reserved word as an identifier then you need to quote it everywhere you use it.如果您使用保留字作为标识符,那么您需要在使用它的任何地方引用它。 So, if you have the table:所以,如果你有桌子:

CREATE TABLE manager (
  "NUMBER"  NUMBER,
  something VARCHAR2(10)
);

Then you insert rows:然后插入行:

INSERT INTO manager VALUES (manager_seq.NEXTVAL,'');
INSERT INTO manager VALUES (manager_seq.NEXTVAL,'');

Then, if you use an unquoted identifier:然后,如果您使用不带引号的标识符:

select * from manager where number = 201;

You get the error:你得到错误:

 ORA-00936: missing expression

But, if you use a quoted identifier with the correct case then you can query the table:但是,如果您使用带有正确大小写的带引号的标识符,那么您可以查询该表:

select * from manager where "NUMBER" = 201;

Which outputs:哪个输出:

NUMBER数字 SOMETHING某物
201 201 null无效的

Note: In Oracle, '' and NULL are identical.注意:在 Oracle 中, ''NULL是相同的。

db<>fiddle here db<> 在这里摆弄

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM