I've working on MYSQL 8.0.11 and testing window functions but getting what I think is an unexpected error via workbench.
SELECT AVG(Volume) OVER(PARTITION BY `Security` ORDER BY DateValue ROWS 19 PRECEDING) AS MAV20
FROM t_EOD_Dly;
In workbenches query window at the Over( I am getting Syntax error: Unexpected '(' (opening parenthesis)
To my best knowledge, brackets are correct. The SQL statement executes correctly with a green tick in the output window.
Interestingly when I drop the same SQL into a stored procedure it won't apply and generates The object's DDL statement contains syntax errors. when attempting to do so.
Is this a bug in build 8.0.11 or am i missing something really simple?
This morning i upgraded both Server and Workbench to 8.0.12 and windows functions now work and I can save to stored procedure.
Related
I'm working with JMeter to load test queries on a mySQL database (memsql server, mySQL syntax). I'm using a gui version of JMeter to create a test plan xml file and then go to another server and run that xml in non-gui mode.
I have two queries running, one that selects and one that inserts. Both queries use parameters taken from a csv file I made with a script.
My SELECT statement works just fine with parameters taken from a csv file but I run into syntax errors with my INSERT statement:
INSERT INTO customer_transactions_current (`column_name1`, ... , `column_name12`)
VALUES ((${r1},${r2},${r3},${r4},${r5},${r6},${r7},${r8},${r9},${r10},${r11},${r12}));
In the section of the query in the gui mode under 'CSV Data Set Config' I choose to delimit the data by ',' and the variable names are r1,..,r12.
Under the query itself I entered the parameter types and again the same names, just as I did for the working SELECT query.
When I run the query I run into a syntax error on the first column (which is of type datetime):
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '19:00:00,75400492,936988,56,1115,5,2156,8,2,3,909,3))' at line 2
The dates I'm entering are of the form: '2018-11-2 20:00:00' and in the csv file they are present without apostrophes.
It seems that the syntax error has something to do with the date and in the position where it holds a space. I tried entering the STR_TO_DATE function for that column but kept getting syntax errors.
BUT when I try to take some values from the file and manually run the query it works fine! So my thoughts are that it has something to do JMeter's conversion of spaces before sending out the query.
Is the problem with my configurations of JMeter? Since the query is OK manually.
Add apostrophes to insert and remove unnecessary parenthesis
INSERT INTO customer_transactions_current ('column_name1', ... , 'column_name12')
VALUES ('${r1}','${r2}','${r3}','${r4}','${r5}','${r6}','${r7}','${r8}','${r9}','${r10}','${r11}','${r12}');
If you have date issue see using STR_TO_DATE
I am trying to update database in mysql but when i use the query in mysql it works perfectly fine......but when i update it through jsp it gives me an error as
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
this is query of JSP: (in content i do not add any closing brackets like ')')
insert into location_"+username+"
values('"+coordinates+"','"+content+"',"+latitude+","+longitude+");
i use stmt.executeUpdate(q1);
the above query is stored in q1..
this is query in mysql:(this works absolutely fine)
insert into location_user1 values('{lat: 19.2222, lng: 73.9781}','random coordinate from database', 19.2222, 73.9781);
i have found out that this error is somewhat common..yet i could not find out any solution...PLease Help!! Thank You!! This error is so frustrating..
Try printing q1 and execute the printed output in MySQL.
At jsp end, the query is not getting properly built and this only is leading to the issue.
Strange situation with my ODBC code ( called from a C library ). Basically, I have the following sequence of events:
Create insert statement ( just a string )
Call SQLPrepare with that insert statement string
Bind the various parameters ( column values ), using
SQLBindParameter
Call SQLExecute to insert the row ( this works, by the way, as I can
see the row in the MySQL DB )
Create "select last_insert_id()" statement string
NOTE: if in SQL Server mode, we would create a "select ##identity"
statement
Bind column using SQLBindCol - this is where I get the "Invalid
descriptor index" error
NOTE: if in SQL Server mode, this works fine, with no error
Call SQLExecDirect to get the last insert id - this never happens
because of SQLBindCol error
Does the standard MySQL ODBC connector require something special in this situation? Does anyone have an ODBC example of this type of "insert" then "get last insert id" behavior? Maybe I need to call "SQLPrepare" before step 6 ( where I bind the column )? Another way to ask this: Should there be an SQLPrepare call for each SQLExecute or SQLExecDirect call?
I know it works directly in SQL, so the problem is my C ODBC code.
Thanks.
For those who are interested, I ended up changing the above steps by adding an SQLPrepare call between creating the "select last_insert_id()" ( step 5 ) and calling SQLBindCol ( step 6 ). Not sure if that would work for others, but it seems to be working rather well for me.
As for research, I looked all over the place online and never found a really good or clear answer. Most comments were about the SQL involved, not ODBC. And the references to ODBC were vague and did not seem to apply to my situation, from what I could see.
My assumption is that the SqlServer ODBC driver I am using handles the missing prepare statement differently ( maybe even better, but that is debatable ) than my MySql ODBC driver.
SQL Server ODBC driver was the one provided by Easysoft
MySql ODBC driver was the one provided with the standard CentOS install of MySql
Hopefully this will help people. Obviously, if people have a better idea, please tell us.
I am using a portal system on my website and modified the ASP code heavily.
Since the website is growing, I want to migrate from MS Acces to MySQL.
Now, I think the portal I'm using (and some code I inputted) aren't MySQL compatable, because when I switch to the MySQL database, I get the following error.
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 5.1 Driver][mysqld-5.1.55-community]You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '[EzModuleID],
[ModName] From EzCore_Plugin Where IsModActive='1'' at line 1
[website]\WWWROOT\BOXX\INCLUDES../../includes/include.asp, line 3736
The SQL string regarding this line is the following:
Select [EzModuleID], [ModName] From EzCore_Plugin Where [IsModActive] = 1;
Im new to MySQL and I can't find why this is giving an error.
I've tried the quote's around 1, removing [], removing the space..
I think that when I figure out why this is causing an error, I can continue modifying the rest to make the website work on mysql.
Lose the square brackets
(I might as well post this as the answer rather than a comment)
In MySQL column and table names can be escaped with the backtick character ` or if the ANSI SQL mode is enabled with double quotes ".
Your WHERE clause (according to the error message) is Where IsModActive='1'. This works if IsModActive is a text column. If it is numeric, drop the single quotes. If IsModActive is a Boolean, change the clause to Where IsModActive IS true.
See: is operator
I'm using SQLAzureMW v3.8.8 but I get lots of errors in the script generated. And the problem is that i don't know in which line is each error generated.
Error #: 105 -- Unclosed quotation mark after the character string
'CREATE PROCEDURE [dbo].[spAdminParametrosGet]
Error #: 156 -- Incorrect syntax near the keyword 'ELSE'.
Error #: 40512 -- Deprecated feature 'NOLOCK or READUNCOMMITTED in
UPDATE or DELETE' is not supported in this version of SQL Server.
Incorrect syntax near '
The TSQL script generates sql stored procedures as strings and are created using dynamic SQL. Some stored procedures have comments inside of it.
May that be the cause or any suggestion to quickly migrate the database to Azure?
It is very much possible that some of the SP and other statements which you want to migrate from SQL Server to SQL Azure are not compatible. Here is a list of supported and unsupported TSQL features:
http://msdn.microsoft.com/en-us/library/windowsazure/ee336250.aspx
Also you haven't mentioned what is your source SQL Server is? As not all SQL Server will full features are supported by SAMQ (3.8 or 4.01)
Also please match your TSQL statements from the unsupported list below and check if any of listed below are part of your TSQL statements:
http://msdn.microsoft.com/en-us/library/windowsazure/ee336253.aspx