I have a query that I am executing in visual studio's query tool and I am getting the following error.
ORA-00972: identifier too long.
Now I believe I am aware that oracle has a 30 byte limit, but this is the query I am trying to execute.
select
"cef_tsroma.tsrido" as "truck",
"cef_tsroma.dosvlg" as "rideNumber",
"cef_v_cw_shipment.shipmentNumber" as "shipmentNumber"
from
"cef_tsroma" left outer join "cef_v_cw_shipment" on "rideNumber" = "shipmentNumber"
where
"truck" = '104490'
Unfortunately I will not be able to change the database structure itself as it is managed by another company that knows nothing about database normalization or is in a situation where they simply cannot or should not. I don't know. Do take into account that "cef_v_cw_shipment" is a view.
truck = '104490' is just a sample integer for testing purposes. I have attempted various solutions but the right method (or looking for the right method) seems to elude me.
Sincerely, me.
P.S. Sorry if this is a dumb question.
Edit:
select
"cef_tsroma"."tsrido" as "truck",
"cef_tsroma"."dosvlg" as "rideNumber",
"cef_v_cw_shipment"."shipmentNumber" as "shipmentNumber"
from
"cef_tsroma" left outer join "cef_v_cw_shipment" on "rideNumber" = "shipmentNumber"
where
"truck" = '104490'
"rideNumber" is now an invalid identifier, I will return to this shortly. I think I'm aliasing it the wrong way but I'm not sure. Goign to find out.
EDIT2:
select
ct.tsrido as "truck",
ct.dosvlg as "rideNumber",
cs.shipmentNumber as "shipmentNumber"
from "cef_tsroma" ct
left outer join "cef_v_cw_shipment" cs
on "rideNumber" = "shipmentNumber"
where "truck" = '104490'
I am going with this syntax now as it is alot cleaner and easier to understand than the previous one. However I am still encountering ORA-00904: "rideNumber": invalid identifier (this likely counts for shipmentNumber aswell in the join line. Trying to figure this one out still, google returns naming tips: no success. Still searching.
Edit3:
select
ct.tsrido as truck,
ct.dosvlg as rideNumber,
cs.shipmentNumber as shipment
from
"cef_tsroma" ct
left outer join
"cef_v_cw_shipment" cs
on
ct.dosvlg = cs.shipmentNumber
where
truck = '104490'
Now following suggestions, this is the current syntax. It currently returns the error message:
ERROR ORA-00904: "CS"."SHIPMENTNUMBER": invalid identifier
I am sorry, I did not design this database> ):
Edit4/solution?
This seems to work, oddly enough.
select ct."tsrido", ct."dosvlg", cs."shipmentNumber" as shipmentnumber
from "cef_tsroma" ct
left outer join "cef_v_cw_shipment" cs
on ct."dosvlg" = cs."shipmentNumber"
where ct."tsrido" = '104956';
The quotes are wrong. "cef_tsroma.tsrido" should be "cef_tsroma"."tsrido"...
On edit2: The new names (aliases) are not affective in the
WHERE
orJOIN
clause. To use a example, the columnX
of the tableDUAL
can be renamed, but must be addressed with the old name in theWHERE
clause:On edit3: Your table and column names look like normal Oracle names, which are case insensitive. So you can remove all the double quotes:
To explain in more details: Oracle table and column names are normally case insensitive. Oracle stores them in uppercase, but you can use them lowercase, uppercase or in any combination in the query.
This changes abruptly if you surround the table or column name with double quotes. Then Oracle insists on exactly that spelling.
So, in your case, the table/view
"cef_tsroma"
doesn't exists, butcef_tsroma
orCEF_TSROMA
or"CEF_TSROMA"
does...you are wrapping the whole table.column with double quotes.
Have you tried using aliases on the tables: