SQL Error: 904, SQLState: 42000 ORA-00904: : invalid identifier - sql

Can below scenario of duplicate alias lead to an error when executed from JDBC or hibernate:
SQL Error: 904, SQLState: 42000 ORA-00904: : invalid identifier
select * From table_master VW
LEFT OUTER JOIN TABLE(test_func(1, 300)) vw
ON VW.table_key = vw.function_key
Facing this in production only. It works fine in test environment.

In my case the DB field didn't exist, and it was returning
SQL Error: 904, SQLState: 42000 ORA-00904: : invalid identifier
After Creating the field, of course it worked,
Double check those fields and make sure they are matching...
Hope it may give you a clue to find the issue

In my case I missed #ManyToOne(fetch = FetchType.EAGER) on that #JoinColumn

Verify that the user with which you are executing the query has the necessary grants for the test_func() function.

Related

Inserting values into a hive table issue

I am attempting to insert values into a specific column in a hive table. The following query does not seem to work:
INSERT INTO table DQ_Rules_Status_Table_PROFILER (Load_TimeStamp) VALUES (2020-01-24) where Load_Ts rlike('Jan 24');
The error message received is as follows:
Error: Error while compiling statement: FAILED: ParseException line 1:86 missing EOF at 'where' near ')' (state=42000,code=40000)
UPDATE DQ_Rules_Status_Table_PROFILER SET Load_TimeStamp = '2020-01-24' WHERE Load_Ts rlike('Jan 24');

Contains condition over clob in sybase db

Can someone help me with the syntax of CONTAINS in Sybase, I have tried below two, and both didn't work :
Query1:
select * from test where column_1 CONTAINS('Set');
Exception:
[Code: 102, SQL State: 37000] Incorrect syntax near 'CONTAINS'.
Query2:
select * from test where CONTAINS(column_1, 'Set');
Exception:
[Code: 102, SQL State: 37000] Incorrect syntax near ')'.
Please help
you have to remove where from your statement and that will be like below
select * from test CONTAINS(column_1, 'Set');
more about contains in sybase read documentation

sql Error in derby - ERROR 42X01: Syntax error: Encountered "KEY"

following query gives error like ERROR 42X01: Syntax error: Encountered "KEY" at line 1, column 48.
I am not able to understand what is the exact issue. column KEY is exist and datatype is integer.
Insert into UOM_TYPE
(UNITS_OF_MEASURE_NO,TYPE,KEY,CREATED_BY,CREATED_DATE,MODIFIED_BY,MODIFIED_DATE,VERSION)
values
(79,'Clinical Property',32,'JRL',DATE('2007-05-04'),'JRL',DATE('2007-05-04'),2);
Please help me to resolve the issue
KEY is a Keyword in derby db. you have to escape it :
Insert into UOM_TYPE
(UNITS_OF_MEASURE_NO,TYPE,"KEY",CREATED_BY,CREATED_DATE,MODIFIED_BY,MODIFIED_DATE,VERSION)
values
(79,'Clinical Property',32,'JRL',DATE('2007-05-04'),'JRL',DATE('2007-05-04'),2);

update table column with Cursor value

Hello I have a problem with cursors here I have this code in my PL/SQL
update CAND_ORDER SET SOURCE_SITE_ID = i.SITE_ID WHERE CAND_ORDER_ID IN
(select CAND_ORDER_ID from CAND_ORDER where SOURCE_SITE_ID is null and SP_TRIAL_MATERIAL_ID in
(select SP_TRIAL_MATERIAL_ID from SP_TRIAL_MATERIAL where SP_RESEARCH_STATION_ID_SOURCE IN
(select SP_RESEARCH_STATION_ID from SP_RESEARCH_STATION where SP_RESEARCH_STATION.CODE IN
(SELECT SITE_CODE from SITE WHERE SITE.SITE_CODE=i.SITE_CODE))));
it gives an error saying:
PLS-00302: component 'SITE_ID' must be declared
ORA-06550: line 17, column 44:
PL/SQL: ORA-00904: "I"."SITE_ID": invalid identifier
which I totally do not understand would you please help pointing what is the problem
I think that the error was in the cursor itself as SITE_ID was not added in the cursor as column. I added it and the problem was solved.

In Oracle SQL , how do you select columns by ordinal position?

I'm trying to study this database , and I want to look for column data based on its position , like so:
select * from V$RESERVED_WORDS where COLUMNS.FIRST like '%'
However, this doesn't seem to work. I get this error:
select * from V$RESERVED_WORDS where COLUMNS.FIRST like "%"
Error at Command Line:10 Column:57
Error report:
SQL Error: ORA-00904: "%": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
I'm using Oracle SQL . Any tips appreciated.
You cant use ordinal, but you need to specify column name. Your query:
SELECT * FROM V$RESERVED_WORDS
WHERE KEYWORD LIKE '%';