2

我在 Oracle 10g Express Edition 中有这部分代码:

CREATE TABLE SALARY (
   GRADE               number(1),
   LOSAL               number(4),
   HISAL               number(4));

   INSERT INTO SALARY VALUES (1,700,1200);
   INSERT INTO SALARY VALUES (2,1201,1400);
   INSERT INTO SALARY VALUES (3,1401,2000);
   INSERT INTO SALARY VALUES (4,2001,3000);
   INSERT INTO SALARY VALUES (5,3001,9999);

我想像 SQL 命令一样输入它,问题是当我点击运行按钮时,我收到以下消息:

ORA-00911: 无效字符

我检查了语法,但一切似乎都很好,有人看到任何错误吗?

4

8 回答 8

1

这部分代码由六个格式正确的语句组成,但它不包含一个格式正确的语句。您需要分别运行每个语句。(顺便说一下,它抱怨的“无效字符”是;前两个语句之间的分号。它删除了最后一个语句末尾的分号,因为它可以告诉它是语句的结尾,但它是不删除语句之间的分号,因为据它所知,它们位于一个大语句的中间。)

于 2012-09-03T04:49:16.793 回答
1

You are mentioning Oracle Express. Are you using the web frontend (through the browser) to run those statements?

If that is the case: the web frontend does not allow running more than one statement at a time.

You need to run each statement separately when using the Oracle Express' web frontend.

SQL Developer from Oracle is free and is much better as a SQL tool. Or use SQL*Plus or use any of the many SQL clients that are out there.

于 2012-09-03T05:12:41.570 回答
0

复制记事本中的所有内容,然后从记事本复制并再次将其粘贴到查询分析器中。在记事本中粘贴将删除任何隐藏的特殊字符。

于 2012-09-03T04:48:15.237 回答
0

您需要commit;在插入语句之后编写语句......希望它能解决您的问题。

于 2012-09-03T04:51:40.740 回答
0

If the problem persist try INSERT ALL See the related post Where's my invalid character (ORA-00911) as well as reference on how to do this: http://psoug.org/snippet/INSERT-ALL_589.htm

于 2012-09-03T04:56:20.183 回答
0

I suspect you want to put the whole thing in an anonymous PL/SQL block and run that, i.e.I hope it should work,correct me if am wrong

BEGIN

    INSERT INTO SALARY VALUES (1,700,1200);
    INSERT INTO SALARY VALUES (2,1201,1400);
    INSERT INTO SALARY VALUES (3,1401,2000);
    INSERT INTO SALARY VALUES (4,2001,3000);
    INSERT INTO SALARY VALUES (5,3001,9999);

 END;
于 2012-09-03T05:21:10.160 回答
0

NUMBER(p) This is a fixed-point number with precision p and scale 0. Equivalent to NUMBER(p,0)

The maximum number that a number can hold in oracle range from 1 to 38 that may be the problem of your error..

This may be helpful for you... http://ss64.com/ora/syntax-datatypes.html

于 2012-09-03T10:44:18.090 回答
-1

when i try to create table and insert the values by ur code it was done successfully.

SQL> CREATE TABLE SALARY (
  2     GRADE               number(1),
  3     LOSAL               number(4),
  4     HISAL               number(4));

Table created.

SQL> 
SQL>    INSERT INTO SALARY VALUES (1,700,1200);

1 row created.

SQL>    INSERT INTO SALARY VALUES (2,1201,1400);

1 row created.

SQL>    INSERT INTO SALARY VALUES (3,1401,2000);

1 row created.

SQL>    INSERT INTO SALARY VALUES (4,2001,3000);

1 row created.

SQL>    INSERT INTO SALARY VALUES (5,3001,9999);

1 row created.

please try one and see

于 2012-09-03T05:07:32.120 回答