SQL: Need help solving 'E26_0002' & 'ORA-00936' Errors with script

27 views Asked by At

Can anyone help with solving following Oracle SQL Errors: (E26_0002) & (ORA-00936)? Below is my script

SELECT Number, ID, NAME, JUDGE, MODIFY_DATE, FROM Mine WHERE Number IN (‘221130G32’)

Thanks!

I added commas where they were missing and it still didn't help.

1

There are 1 answers

0
Littlefoot On

Remove a comma in front of the from keyword (but that's a minor mistake). There seems to be a worse one.

Column name can't be Number; that's a reserved word (for datatype).

SQL> create table mine (number varchar2(10));
create table mine (number varchar2(10))
                   *
ERROR at line 1:
ORA-00904: : invalid identifier

It can be, but only if you enclose its name into double quotes, but then you have to reference that column using double quotes and exactly the same letter case every time (and that would be really bad idea):

SQL> create table mine ("Number" varchar2(10));

Table created.

As condition you used clearly says that column's contents is a string, then rename the column and use appropriate datatype.

Anyway, presuming that column name really is Number, then you'd

SQL> create table mine as
  2    select '221130G32' as "Number", 1 id, 'Little' name, 'Foot' judge, sysdate modify_date from dual;

Table created.

SQL> select "Number", id, name, judge, modify_date
  2  from mine
  3  where "Number" in ('221130G32');

Number            ID NAME   JUDG MODIFY_DA
--------- ---------- ------ ---- ---------
221130G32          1 Little Foot 16-DEC-22

SQL>