Syntax error: Encountered "<EOF>" in derby on DROP SEQUENCE statement - sql

Some sequences were created because of the error described here. To keep everything clean I tried to delete them with the command DROP SEQUENCE seqname;. It produces me the following message:
Error code -1, SQL state 42X01: Syntax error: Encountered "" at line 1, column 20.
Line 1, column 1
Execution finished after 0 s, 1 error(s) occurred.
I guess it is because I work on Windows machine which has different EOF marker. But how to solve the problem in SQL?

After several trials the solution is DROP SEQUENCE sequence_name RESTRICT which was found here. Adding RESTRICT to the SQL statement solves the problem

Related

Database Error: 001003 (42000): SQL compilation error

I am getting this error when using dbt cli 0.21.1 with Snowflake:
Encountered an error: Database Error 001003 (42000): SQL compilation error: syntax error line 1 at position 31 unexpected '<EOF>'. syntax error line 1 at position 30 unexpected '.'.
... when running "dbt build". I have stripped down my models to the minimum and get the same error whatever I do. I have done "dbt clean". The results of "dbt debug" and "dbt parse" look fine.
In the dbt.log file, I can see it fails on a Snowflake command:
create schema if not exists FT.
... with the SQL compilation error message shown above.
I found the same error in the Snowflake query history, with the same command text. So I tried it by hand in the Snowflake console. Lo and behold, it works fine without the trailing period, but Snowflake produces exactly this error with that trailing period.
So it seems like dbt and Snowflake disagree about whether a SQL command should end with a period. Which one has a bug? Or is there a way to tell one or the other to change?
I forgot that I had created a generate_schema_name macro -- and it was messing up the schema name, turning it into an empty string. The create schema command was trying to create a schema named "FT." but because the schema name was blank, it ended up as "FT." -- and the trailing period confused me.
Mea culpa.
Hope this description ends up helping someone else who makes the same mistake.

Postgres solving a syntax error caused by a dash (-)

I am trying to query from a database called physionet-data.mimiciii_clinical.diagnoses_icd
PostgresSQL returns the following error message:
quan.sql:273: ERROR: syntax error at or near "`"
LINE 132: from `physionet-data.mimiciii_clinical.diagnoses_icd` icd
I think it is caused by the dash. If I change the `for ' the same error comes up
quan.sql:273: ERROR: syntax error at or near
"'physionet-data.mimiciii_clinical.diagnoses_icd'"
Any clue on how to fix that?
You would need to quote that schema name, using double-quotes:
select ...
from "physionet-data".mimiciii_clinical.diagnoses_icd
Note that quoting an identifier makes it case-sensitive. You would need to ensure that the character case the schema was created with matches the one you are using here.
Using identifiers that require quoting is not a good idea in general; as you are fiding out, this requires quoting them every where you use it later on. If that's not too late, I would recommend changing the schema name to a name that does not require quoting.

Cannot import .sql to PostgreSQL. Syntax error

Probably a very simple error but I cannot work it out for the life of me. Basically, I am loading a .sql dump into a postgres DB using
psql testdb< C:\Users\Callum\Desktop\backup.sql
However, I get the error:
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `table1`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `table2` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `table3` WRITE;
I have been trying to work this out for days and could not find any anwsers online.
Thanks
Are you importing from MySQL? You don't need backticks here, you can take them out.

Firebird select statement gives SQLSTATE = 42S02

I've made a very simple database and am trying
select * from klant;
I've verified the table exists, and last week was able to see data in it. Today however I keep getting
Statement failed, SQLSTATE = 42S02
Dynamic SQL Error
-SQL error code = -204
-Table unknown
-KLANT
-At line 1, column 15
The same select query in flameRobin gives the following error:
Error: *** IBPP::SQLException ***
Context: Database::Statistics
Message: isc_database_info failed
SQL Message : -902
can't format message 13:98 -- message file C:\WINDOWS\SYSTEM32\firebird.msg not found
Engine Code : 335544727
Engine Message :
Error writing data to the connection.
I have copied the firebird.msg to the system32 folder so it should be able to find it there.
Any pointers toward the solution would be greatly appreciated. Similar question all seem to point toward issues with transactions, I can't see that being the problem here.
Edit:
I'm using the included ISQL tool from firebird and start the session by connecting to the database that includes my table. Same for flamerobin, first connect to database, I can see the table that i want to select from but it gives this error.
Edit2:
Finally reinstalled Firebird making sure I gave it admin right, which I think it had before, but wasn't sure about. This seems to have fixed it.

Error in executing SQL statement with PostgreSQL

I create a new database 'sakila' with pgAdmin III in my local PostgreSQL database, then executed these sql statements:
sakila-schema.sql then sakila-data.sql
The first statement executed without error, however the second SQL did produced error when executed:
ERROR: syntax error at or near "1"
LINE 112: 1 PENELOPE GUINESS 2006-02-15 09:34:33
^
********** Error **********
ERROR: syntax error at or near "1"
SQL state: 42601
Character: 2511
How to fix this error?
You can't COPY FROM stdin with pgAdmin, you have to use psql tool, the problem is that pgAdmin is not a console application, there is no easily usable stdin so you can't COPY from Standard Input .