I have a column name in one of my tables called: 3RD_DIAG_CODE - VARCHAR2 (10 Byte)
When I try to run a query, it gives me the following error highlight
Check your specification, but in SQL Server we would have to enclose that column name in square brackets: [3RD_DIAG_CODE]
If you are using column names that start with a number then you need to use double quotes. For example:
create table foo (
"3RD_DIAG_CODE" varchar2(10 byte) --make sure you use uppercase for variable name
);
insert into foo values ('abc');
insert into foo values ('def');
insert into foo values ('ghi');
insert into foo values ('jkl');
insert into foo values ('mno');
commit;
select * from foo;
3RD_DIAG_C
----------
abc
def
ghi
jkl
mno
select 3RD_DIAG_CODE from foo;
RD_DIAG_CODE
------------
3
3
3
3
3
select "3RD_DIAG_CODE" from foo;
3RD_DIAG_C
----------
abc
def
ghi
jkl
mno
Edit: As for the error message itself, you are probably (as BQ wrote) missing a comma from the select clause.
You probably have two columns listed without a comma between them.
create table t (id number primary key, 3d varchar2(30))
Error at Command Line:1 Column:39
Error report:
SQL Error: ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
create table t (id number primary key, "3d" varchar2(30));
table T created.
desc t
Name Null Type
---- -------- ------------
ID NOT NULL NUMBER
3d VARCHAR2(30)
> select id, 3d from t --[as @gsiem mentions: THIS IS BAD]
ID 3D
---------------------- --------
> select id, "3d" from t
ID 3d
---------------------- ------------------------------
> select id, [3d] from t
Error starting at line 7 in command:
select id, [3d] from t
Error at Command Line:7 Column:11
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
> select id 3d from t
Error starting at line 8 in command:
select id 3d from t
Error at Command Line:8 Column:10
Error report:
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action: