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

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);

Related

How to drop a column starting with a Digit in Netezza

Due to some error while uploading data, extra columns got created and one of the column names became 84. Trying to remove that column but getting following error:
org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error [1100] [HY000]: ERROR: 'ALTER TABLE XXX.XXXXX
DROP 84'
error ^ found "84" (at char 44) expecting an identifier, identifiers must begin with a letter
You can find examples of how to handle identifiers that does does not begin with a letter. You can wrap the identifier in double quotes
https://www.ibm.com/support/knowledgecenter/SSULQD_7.2.1/com.ibm.nz.dbu.doc/c_dbuser_handle_sql_identifiers.html

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

Invalid table name while bulk insert in oracle

I am trying to insert values into Oracle table using Bulk Insert query but getting below error
ORA-00903: invalid table name
00903. 00000 - "invalid table name"
*Cause:
*Action:
Error at Line: 4 Column: 5
Here is my query
BULK INSERT TEST1.STUDENT
FROM 'C:\Users\Alan\Desktop\STUDENT.txt'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
);
Why is this error coming. Is there some issue with query? Please help. Thanks
Update
I changed by file format to CSV and wrote below query
LOAD DATA
INFILE 'C:\Users\Alan\Desktop\STUDENT.csv'
INTO TABLE TEST1.STUDENT
FIELDS TERMINATED BY ","
(ID,
NAME);
but above query is giving
ORA-00928: missing SELECT keyword
00928. 00000 - "missing SELECT keyword"
*Cause:
*Action:
Error at Line: 16 Column: 2
What is wrong in the above syntax?
This is not Oracle syntax at all. If you need to load data from file to table please use either SQLoader or External table
Some documentation about External table and SQLoader
If you're using SQLDeveloper you can also use import facility.
Please also have a look on that thread.
[EDIT}
LOAD DATA
INFILE 'C:\Users\Alan\Desktop\STUDENT.csv'
INTO TABLE TEST1.STUDENT
FIELDS TERMINATED BY ","
(ID,
NAME);
This is not a query. This is content of control file. Please save it to file load.csv then run cmd (or shell if yuo're on Linux) and type:
sqlldr user/pass control=load.ctl
Some examples you can find here.

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

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.