There are a lot of questions like this, but I couldn't find one that solved my problem-
Can someone tell me if my syntax is wrong? I'm trying to insert data into a sql table.
INSERT INTO awards values ('Academy of Motion Picture Arts and Sciences’,'2007',’Best Picture','Oscar’);
I'm getting this error:
ERROR: syntax error at or near "2007"
LINE 1: ...s ('Academy of Motion Picture Arts and Sciences’,'2007',’Bes...
Did you paste this from somewhere? Check and replace your quote character, you're using an invalid character (e.g. ’ instead of ') for quoting.
Related
I have a device container with the name 1cbfce15ec4d which houses some my data. I know for a fact there's data in there, but when I try a simple query in the griddb shell, I got the following error:
gs[public]> sql select * from 1cbfce15ec4d;
D20332: An unexpected error occurred while executing a SQL. : msg=[[240001:SQL_COMPILE_SYNTAX_ERROR] Parse SQL failed, reason = Syntax error: 1cbfce15ec4d; on executing query (sql="select * from 1cbfce15ec4d") (db='public') (user='admin') (appName='gs_sh') (clientId='a6d92f48-e558-440-86dd-a05e949fa726:1') (clientNd='{clientId=3, address=127.0.0.1:55744}') (address=127.0.0.1:20001, partitionId=983)]
I am not exactly sure what is going on here -- at first I assumed my data must be corrupt or empty, but that is not the case. It seems to be a case of the shell dying trying to process something about that container name.
Any ideas?
According to the manual :
"If the name of a table or a column contains characters other than ASCII alphanumeric characters and underscore, or if the first character of the name is a number in a SQL statement, enclose the name with double quotation marks."
Try select * from "1cbfce15ec4d"
Select * from mytable where field=
'ce7bd3d4-dbdd-407e-a3c3-ce093a65abc9;cdb597073;7cf6cda5fc'
Getting Below Error while running above query in Hive
FAILED: ParseException line 1:92 character '' not supported here
<EOF> here means End Of File. When you get an "unexpected End Of File" error it means the parser reached the end of the query unexpectedly. This typically happens when the parser is expecting to find a closing character, such as when you have started a string with ' or " but have not closed the string (with the closing ' or ").
When you come across these types of errors it is good to check that your query can be parsed correctly. In addition, the error gives you the location where the parser failed: line 1:92 in this case. You can usually look at this location (character 92 of the query) and work backwards to find the problem character.
Try adding the database name to the "from" statement as below.
Select * from my_db_name.mytable where field= 'ce7bd3d4-dbdd-407e-a3c3-
ce093a65abc9;cdb597073;7cf6cda5fc';
Hive uses the default database when no database was previously specified.
I was trying to load the data from the csv file into the Oracle sql developer, when inserting the data I encountered the error which says:
Line contains invalid enclosed character data or delimiter at position
I am not sure how to tackle this problem!
For Example:
INSERT INTO PROJECT_LIST (Project_Number, Name, Manager, Projects_M,
Project_Type, In_progress, at_deck, Start_Date, release_date, For_work, nbr,
List, Expenses) VALUES ('5770','"Program Cardinal
(Agile)','','','','','',to_date('', 'YYYY-MM-DD'),'','','','','');
The Error shown were:
--Insert failed for row 4
--Line contains invalid enclosed character data or delimiter at position 79.
--Row 4
I've had success when I've converted the csv file to excel by "save as", then changing the format to .xlsx. I then load in SQL developer the .xlsx version. I think the conversion forces some of the bad formatting out. It worked at least on my last 2 files.
I fixed it by using the concatenate function in my CSV file first and then uploaded it on sql, which worked.
My guess is that it doesn't like to_date('', 'YYYY-MM-DD'). It's missing a date to format. Is that an actual input of your data?
But it could also possibly be the double quote in "Program Cardinal (Agile). Though I don't see why that would get picked up as an invalid character.
EDIT: Thanks guys. It was truly just a formatting error of the single-quotation mark from the source code I copied. Thanks a lot!
Codes:
USE Library;
INSERT INTO myLibrary VALUES (
‘SQL Bible’
,‘Alex Kriegel’
,‘Boris M. Trukhnov’
,‘Wiley’
,888
,‘April 7,2008’
,‘978-0470229064’
,‘English’
);
Output:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '‘'.
Question
What is the problem here? I am new to SQL. Thanks in advance!
In SQL, strings are defined with the ' characters, not ‘ and ’
Looks like you're using the wrong character to encapsulate your strings. Instead of the ‘ character, you need to use either a ' or a ":
USE Library;
INSERT INTO myLibrary VALUES (
"SQL Bible"
,"Alex Kriegel"
,"Boris M. Trukhnov"
,"Wiley"
,888
,"April 7,2008"
,"978-0470229064"
,"English"
);
If you did a copy/paste from some software, like Word, it can have formatting attached. Your SQL engine will not interpret it.
Take the code, put it into notepad or some other simple text editor (notepad + or jedit are two that I use) and do a replace the open quote and the end quote with a ' or ".
How I can execute sql statements including comments in pgadmin sql editor?
Neither -- nor /* syntax is working, that is gives me this error:
ERROR: syntax error at or near ""
LINE 1: /*
For comments in PGAdmin SQL editor use -- or /*.... */ notation.
If you use something like
""" comment """
select * from database
you get following syntax error
ERROR: syntax error at or near """" comment """".