I'm new to Oracle SQL and I'm currently working on an Oracle SQL view in Oracle SQL Developer.
I need two parameters in my View
fruitType (string)
fruitNumber (int)
I tried the following (simplified) statement in Oracle SQL Developer:
CREATE VIEW FRUITSRESULT (fruitType, fruitNumber) AS
SELECT
fruit_col1 as FruitType,
fruit_col2 as FruitNumber
fruit_col3 as FruitInfo
FROM
FRUITGARDEN
WHERE
fruit_col1 = fruitType
fruit_col2 = fruitNumber
;
Unfortunately this does not work, I always get the following error:
Error starting at line : 1 in command -
...
ORA-00904: "FRUITNUMBER": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Do you know how to solve this error?
Is it actually possible to create a parameterized View in Oracle SQL?
Is it actually possible to create a parameterized View in Oracle SQL?
No, that is not possible.
What you are thinking of as parameters are the column aliases for the output:
CREATE VIEW FRUITSRESULT (fruitType, fruitNumber, FruitInfo) AS
SELECT fruit_col1,
fruit_col2,
fruit_col3
FROM FRUITGARDEN;
Will output the values fruit_col1, fruit_col2 and fruit_col3 with the columns aliased to fruitType, fruitNumber, and FruitInfo (respectively). They are not, as you assumed, input parameters.
Related
Here I am using Oracle SQL developer and I need to update a table in an another schema. Here is the update query which I have written.
update dcs.lte_pin_register set pin = ''
where dcs.lte_pin_register.subscriber_seqno = dcs.subscriber.subscriber_seqno
and dcs.subscriber.sub_number = '?';
In the above query,
dcs -> Refer to another schema in the database
lte_pin_register and subscriber are two tables in the dcs schema
subscriber_seqno and sub_number are the columns in the respective tables.
However when I am going to execute the above query using a valid sub_number I am getting an error mentioning follows.
Error report -
SQL Error: ORA-00904: "DCS"."SUBSCRIBER"."SUB_NUMBER": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
I can call a column name in the same schema for the update query using (tableName.columnName). But how can I modify the above query to refer to columns in tables in different schemas?
You have to use a co-related subquery to achieve this -
UPDATE dcs.lte_pin_register
SET pin = ''
WHERE EXISTS (SELECT 1
FROM dcs.subscriber
WHERE dcs.lte_pin_register.subscriber_seqno = dcs.subscriber.subscriber_seqno
AND dcs.subscriber.sub_number = '?');
SELECT sur.* FROM table_name
Whenever I run this code in SQLDeveloper it it gives me the error
ORA-00904: "SUR": invalid identifier
00000 - "%s: invalid identifier"
I'm not sure how to fix this and haven't been able to find anything online. The reason I have to use this format is because it follows a format already being implemented by previous developers and I have to adhere to that standard.
Has anyone had any experience with this?
Try this
SELECT sur.* FROM table_name sur;
You have used a sur alias for referring all the columns of the table table_name but before you can use that you need to give table table_name an alias like sur
However the below query will work fine as you are using the actual table name instead of a different alias name.
select table_name.* from table_name;
Here, you ask to list columns from table "SUR" but since no such table exists in "from" clause, Oracle raises this error.
There are 2 options here:
Give an alias (a second name) to any of the table in from clause
For eg:
select sur.* from tablename1 sur, tablename2 foo where sur.col1=foo.col1
Use table name itself rather than using column alias "SUR"
For eg:
select tablename1.* from tablename1, tablename2 where tablename1.col1=tablename2.col1
Refer: http://www.techonthenet.com/oracle/alias.php
Hi I have the following code
SELECT entertainer_id,
entertainer_groupname
FROM casestudy_entertainer
INNER JOIN casestudy_availability ON
casestudy_entertainer.entertainer_id
= CASESTUDY_AVAILABILITY.AVAILABILITY_ENTERTAINERID
INNER JOIN casestudy_calendardates ON
CASESTUDY_AVAILABILITY.AVAILIBILITY_CALENDARDATEID
= casestudy_calendardates.calendar_Id
WHERE entertainer_type = '&Entertainer_TYPE'
AND casestudy_calendardates.calendar_date = '&Event_date'
And I don't seem to be able to figure out what its not liking when I run this.
It gives me the following error
ORA-00904: "CASESTUDY_AVAILIBILITY"."AVAILIBILITY_CALENDARDATEID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 7 Column: 4
I do have all the tables in place with all the correct rows.
The only thing is I have no data as of yet, Could this possibly be the issue?
You should try the lower case for the table/column identifiers(like in from/inner join clauses):
SELECT entertainer_id,
entertainer_groupname
FROM casestudy_entertainer
INNER JOIN casestudy_availability ON casestudy_entertainer.entertainer_id = casestudy_availability.availability_entertainerid
INNER JOIN casestudy_calendardates ON casestudy_availability.availibility_calendardateid = casestudy_calendardates.calendar_id
WHERE entertainer_type = '&Entertainer_TYPE'
AND casestudy_calendardates.calendar_date = '&Event_date'
This Error is caused by a special character in one of the columns of the database table. DBA will be able to help you.
You have same tablenames in your tables while left joining.
Change tablename of one , it will work.
no data is not the issue, you won't simply get a null result. ORA-00904 indicates, that you used a column that does not exist or does not comply to the Oracle specification.
Please check for correct naming. You might be better of with shorter names or at least table aliasses to get to code more readable.
Without knowing your table structure I cannot tell you where the error is. do a describe table_name;
It would also help to have the oracle version number SELECT * FROM V$VERSION or SELECT version FROM V$INSTANCE
and your client software you are using
What is interesting, Oracle gives that message not only if the name of the column is bad, but also if the name of the table/alias is bad - not defined alias, twice defined (as mentioned #PrajwalRai), error in the table name.
Old question, but maybe it helps:
sometimes you copy and paste text from a source that has a different character set ...
Type it over in sql-dev for instance and see if the error is gone
I was able to clear this error in an Oracle DB using Oracle SQL Developer by placing strings in single quotes instead of double quotes
Hello I have created a Database Link from Oracle to SQL Server 2008 using Oracle Gateway.
DB LINK:
create public database link mssql
connect to "user" identified by "password"
using 'gateway-SID';
When I use a simple query as SELECT * FROM TABLE#MSSQL the results are clearly ok.
The problem occurs when I select a distinct column from a table e.g.
SELECT COLUMN_NAME FROM TABLE#mssql
I get a query error from my SQL Developer saying:
ORA-00904: "CUSTOMERID": invalid identifier
00904. 00000 - "%s: invalid identifier"
Cause:
Action:
Error at Line: 1 Column: 8
Can anyone help me on this please?
(Disclaimer: I'm no SQL Server expert, but I'll give it a go)
SQL Server is case sensitive - you have to quote your column names, so instead of
SELECT COLUMN_NAME FROM TABLE#mssql
you need
SELECT "COLUMN_NAME" FROM TABLE#mssql
or even
SELECT "COLUMN_NAME" FROM "TABLE"#mssql
See Oracle forums on SQL Server, Oracle Gateway and ORA-00904
I'm new to using Oracle SQL Developer and to using an Oracle DB (have mainly used MySQL before)
I'm trying to do something like:
select * from content_definition where content_id = "hhhh233";
Where content_id is:
VARCHAR2(1000 BYTE)
But am getting:
ORA-00904: "hhhh233": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 1 Column: 52
I'm not really understanding why this isn't working as I used to do queries like this all the time with MySQL. I have been searching on this but nothing seems to be for my specific use case. I would appreciate if anyone can set me in the right direction on this. Thanks
You need to use single quotes for character data; double quotes signify identifiers and aliases:
select * from content_definition where content_id = 'hhhh233';
String delimiter in Oracle is a single quote ('), like this:
select * from content_definition where content_id = 'hhhh233';
Double quotes are only used for identifiers (e.g. column names and tables).