2

I have this portion of code in 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);

and I want to enter it like a SQL command, the problem is that when I hit the Run button I got the following message:

ORA-00911: invalid character

I have checked the syntax, but everything seems to be fine, does anybody see any mistake?

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Layla
  • 5,234
  • 15
  • 51
  • 66

8 Answers8

1

That portion of code consists of six correctly-formatted statements, but it does not consist of a single correctly-formatted statement. You'll need to run each of the statements separately. (The "invalid character" that it's complaining about, by the way, is the semicolon ; between the first two statements. It's removing the semicolon at the very end of the last statement, because it can tell it's the end of the statement, but it's not removing the semicolons between statements, because as far as it knows they're in the middle of one big statement.)

ruakh
  • 175,680
  • 26
  • 273
  • 307
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.

0

copy everything in notepad and then copy it from notepad and paste it in query analyzer again. pasting in notepad will remove any hidden special character.

Raheel
  • 595
  • 8
  • 21
0

You need to write commit; statement after insert statement... Hope it will solve your problem.

bluish
  • 26,356
  • 27
  • 122
  • 180
user968441
  • 1,471
  • 9
  • 22
  • 48
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

Community
  • 1
  • 1
Conrad Lotz
  • 8,200
  • 3
  • 23
  • 27
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;
thar45
  • 3,518
  • 4
  • 31
  • 48
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

Suraj Shrestha
  • 1,790
  • 1
  • 25
  • 51
-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

Girish R Acharya
  • 140
  • 5
  • 15