While using H2 in postgresql mode, I am unable to load data.sql with above error
basically getting error message expected INDEX, ,, );
Issue was sytax error in sql create statement
there was missing bracket ")" at end of create statement query
create table foo (testdate date, card_uuid uuid, PRIMARY KEY (card_uuid); <- missing bracket here
Related
I am getting "JdbcSQLSyntaxErrorException: Column "REAL" not found" exception on inserting a record in the H2 Db table from an Springboot project.
My query is:
INSERT INTO `bharatqr_provider_config` (`id`, `provider_name`, `provider_base_url`, `provider_username`, `provider_password`, `provider_key`, `status`, `created_by`, `created_time`, `lock_id`, `modified_by`, `modified_time`, `timezone`, `auto_check_status_enabled`, `upi_check_status_enabled`,`terminal_type`,`qr_type`) VALUES (1,'HDFC', 'http://localhost:6061','','','','ACTIVE','me','2017-12-06 15:23:42',1,'me', '2017-12-06 15:23:42','IST', 0, 1,"REAL","INTERNAL"), (2,'DUMMY','http://localhost:6061','me','me','me','ACTIVE','me', '2018-01-10 12:24:03',1,'me','2018-01-10 12:24:03', NULL, 0, 0,"NONE","INTERNAL");
From the exception It's saying that Column "REAL" not found", But "REAL" is not the column name it's a value which have to insert in the column terminal_type.
"REAL" and "INTERNAL" are not values, they are identifiers in every standard-compliant database system.
Character string literals in SQL are surrounded by single quotes, you need to write them as 'REAL' and 'INTERNAL'.
I am using a SimpleJdbcInsert to insert rows into a PostgreSQL database. However, I get an the following error:
Caused by: org.postgresql.util.PSQLException: ERROR: INSERT has more
target columns than expressions.
org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [INSERT
INTO product (product_id,product_name,product_code,in_
stock,product_category) VALUES(?)]; SQL state [25P02]; error code [0];
ERROR: current transaction is aborted, commands ignored until end of
transaction block; nested exception is
org.postgresql.util.PSQLException: ERROR: current transaction is
aborted, commands ignored until end of transaction block
The number columns is exactly the same as the number of values I am trying to insert when I print out the MapSqlParameterSource object shown below:
Parameters Names ::
[
product_id,
product_name,
product_code,
in_ stock,
product_category
]
Parameters Values :: [{
product_id=1518,
product_name=Sofa,
product_code=150,
in_stock=true,
product_category=null,
}]
The product_id is the primary key and it is not null. Could the problem be because I am not using an auto-generated primary key? I still do not understand why that would be a problem.
The columns shown in the error message are precisely the same as the columns in the parameter list I'm printing. The values also tally with the number of columns as well, so I'm really baffled why PostgreSQL is giving this error. Please help!
I was able to solve it with a different solution to using Spring JDBC.
I was trying to import data from an oracle database table using a ctl file. Unfortunately, it doesn't work due to a syntax error and, for my efforts, I can't understand why.
SQL code:
sqlldr USERID=user/password, CONTROL=C:\wkt_building001.ctl, LOG=C:\ulcase1.log
file ctl code:
OPTIONS (readsize=20000000, DIRECT=TRUE)
UNRECOVERABLE LOAD DATA
CHARACTERSET UTF8
INFILE 'C:/wkt_building.txt.001'
APPEND
PRESERVE BLANKS
INTO TABLE wkt_building
FIELDS TERMINATED BY ' ' TRAILING NULLCOLS
(
BUILDING_ID,
BUILDING CHAR(100000)
)
error:
org.jkiss.dbeaver.model.sql.DBSQLException: Errore SQL [900] [42000]: ORA-00900: istruzione SQL non valida
at...
Caused by: java.sql.SQLSyntaxErrorException: ORA-00900: istruzione SQL non valida
at ...
Caused by: Error : 900, Position : 0, Sql = sqlldr USERID=user/password, CONTROL=C:\wkt_building001.ctl, LOG=C:\ulcase1.log data=C:\wkt_building.txt.001, OriginalSql = sqlldr USERID=user/password, CONTROL=C:\wkt_building001.ctl, LOG=C:\ulcase1.log data=C:\wkt_building.txt.001, Error Msg = ORA-00900: istruzione SQL non valida
at ...
thank you in advance
in the wrong initial command the ip address, the port and the database name are missing, this is the correct version:
sqlldr USERID=user/password#10.0.0.116:1521/name_database CONTROL=wkt_face001.ctl LOG=ulcase1.log
Also to configure the connection on cmd follow this guide that uses net menager should have all the steps:
https://www.youtube.com/watch?v=86WxgQdNTYU
I try to execute following query:
SET DATABASE SQL SYNTAX MYS TRUE;
and then:
INSERT INTO mytable (id, age) VALUES (1, 1)
ON DUPLICATE KEY UPDATE id=2, age=33;
I get error:
INSERT INTO mytable (id, age) VALUES (1, 1)
ON DUPLICATE KEY
[2020-10-23 11:09:42] [42590][-5590] unexpected end of statement: required: UPDATE : line: 2
What do I wrong ?
The OP reports this in a comment:
PUBLIC.PUBLIC> SET DATABASE SQL SYNTAX MYS TRUE [2020-10-23 11:23:14] completed in 4 ms
PUBLIC.PUBLIC> INSERT INTO tblUserMetadata (userMetadataId, portalId) VALUES (1, 1) ON DUPLICATE KEY [2020-10-23 11:23:14] [42590][-5590] unexpected end of statement: required: UPDATE : line: 2
The lines show an SQL client is being used to run a script. The SQL client pre-parses the statement and thinks the statement is finished after the keyword KEY, and the keyword UPDATE is the start of a new statement. So it tries to send the incomplete SQL query to the database engine.
The MySQL syntax is in operation because the command was accepted and executed.
You can check the property settings by selecting from a system table:
SELECT * FROM information_schema.system_properties
The statement below returns true when the MySQL compatibility mode has been set:
SELECT property_value FROM information_schema.system_properties
WHERE property_name = 'sql.syntax_mys'
I am working on an Advantage Database Server 8.1 and I have created a new table. I want to add a unique constraint for the combination of 2 columns.
I tried
ALTER TABLE TableName
ADD CONSTRAINT ConstraintName
UNIQUE (ColumnName1, ColumnName2)
but I get the error
"ERROR IN SCRIPT: poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [Extended Systems][Advantage SQL Engine]Expected lexical element not found: You are missing the column names. -- Location of error in the SQL
statement is: 33 (line: 2 column: 5)"
Ok the solution I found is:
CREATE UNIQUE INDEX ConstraintName ON TableName (ColumnName1, ColumnName2);