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 """".
Related
I am trying to make my big migration more self explaining and that's why I need to add some comments to it. However, I tried a few approaches and haven't succeeded with them.
I tried:
//
#
<!-- TEXT -->
Error:
SQL State : 42601
Error Code : 0
Message : ERROR: syntax error at or near "//"
Position: 1
Is there a way I can add a comment to flyway SQL migration?
The following should work on all supported databases:
/* Single line comment */
/*
Multi-line
comment
*/
-- Sql-style comment
And additionally on MySQL and MariaDB:
# MySQL-style single line comment
When we were upgrading to spring-boot 2.5 we found that there is need to have a space after first two hyphens -- with SQL style comments
Use ANSI SQL's -- for comments!
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.
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.
I have DB2 v9.7 client driver to access DB2 instance which is installed on Z/OS environment. I am trying to write and execute an anonymous procedure by the help of Toad for DB2 4.7. Unfortunately, none of the given example codes on the internet hurdled the syntax errors. Whatever i try, even very simple ones, not worked properly. I am curious about is there an execution mode of Toad or something that i missed on my tries. Here are my tries and syntax errors that i have received:
DECLARE
somechr VARCHAR2(255);
BEGIN
somechr:='some value';
END;
The sample above throws these errors:
DB2 Database Error: ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "VARCHAR2" was found following "". Expected tokens may include: "TABLE STATEMENT , . SCROLL INSENSITIVE SENSITIVE ASENSITIVE ". SQLSTATE=42601
DB2 Database Error: ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "SOMECHR" was found following "". Expected tokens may include: "DECLARE". SQLSTATE=42601
DB2 Database Error: ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "END-OF-STATEMENT" was found following "". Expected tokens may include: "DECLARE". SQLSTATE=42601
The last one vanishes when i change the 'some value'; to 'some value';--
Some examples uses following syntax:
BEGIN
DECLARE somechr VARCHAR2(255);--
somechr:='some value';
END;
However, this syntax throws exception too:
DB2 Database Error: ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "SOMECHR" was found following "". Expected tokens may include: "SECTION". SQLSTATE=42601
At last i have tried this:
BEGIN
DECLARE SECTION BEGIN
somechr VARCHAR2(255);--
END;
somechr:='some value';--
END;
And got these:
DB2 Database Error: ERROR [42612] [IBM][DB2] SQL0084N An EXECUTE IMMEDIATE statement contains a SELECT or VALUES statement. SQLSTATE=42612
DB2 Database Error: ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "SOMECHR" was found following "". Expected tokens may include: " GET SQL SAVEPOINT HOLD FREE ASSOCIATE". SQLSTATE=42601
Besides these tries, some noted that use of '--#SET TERMINATOR #' at the beginning of the code, nevertheless it did not help as well for all examples above. I have given tries by changing the ';' to symbol '#' for all combinations (with or without '--#SET TERMINATOR #' statement), but erros does not seem to be vanished.
I work with DB2 LUW, not z/OS. That said, you might try this:
BEGIN
DECLARE V_SOMECHR NVARCHAR(255);
SET V_SOMECHR = 'some value';
END
My experience in DB2 LUW is that the declarations have to be inside the BEGIN block, and must come first, but there is no heading stating that it is a DECLARE section. You can place your procedural code immediately after the last declaration. Not sure if this will be the case in z/OS.
I have the following ruby database insert using ODBC. Connection is fine.
dbh.do( "INSERT INTO prowlerRunningResults(ProwlerDriver, SourceURL, Title, DestinationURL, FileSource, FileType, FileName, LastModified, FileSize, HashMD5, HashSHA256, ImageBinary)
VALUES (#{driver}, #{source}, #{title}, 'NA', #{imgSrc}, #{fileType}, #{fileName}, #{lastModified}, #{fileSize}, #{md}, #{sha}, #{binary} )" )
However, I am getting an Error message: 37000 (102) [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ','. Which could be a little more helpful considering the number of commas involved. Nevertheless, having looked and looked I simple can't see the problem !!
So to the questions:
Can you detect the syntax error that is being reported?
I would like to insert NULL instead of 'NA' - but have no idea how to do that in ruby. How is it done?
EDIT:
Could be a problem with the DB Schema.
The physical DB has FileSize as an int. So I updated the code to insert #{fileSize.to_i} but the ImageBinary is a varbinary(MAX) - perhaps I could write the file out as HEX to a string? What do you think?
To debug, try looking at the expanded string. You can puts, log, or raise.
sql = "INSERT INTO prowlerRunningResults(ProwlerDriver, SourceURL, Title, DestinationURL, FileSource, FileType, FileName, LastModified, FileSize, HashMD5, HashSHA256, ImageBinary)
VALUES (#{driver}, #{source}, #{title}, 'NA', #{imgSrc}, #{fileType}, #{fileName}, #{lastModified}, #{fileSize}, #{md}, #{sha}, #{binary} )"
puts sql
logger.info sql
raise sql
You probably forgot some single quotes for some string data.