Error Code 1064 with ') ENGINE = InnoDB' at Line 2 - innodb

13:28:50 CREATE TABLE IF NOT EXISTS mydb.Customers ( ) ENGINE = InnoDB Error Code: 1064. 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 ') ENGINE = InnoDB' at line 2 0.00031 sec
enter image description here

You must include some column definitions between the parens.
(Note: 1064 is very good at pointing exactly to the spot where the problem is.)

Related

PeopleSoft Power Query convert inside of a Case statement

Okay I'm using PeopleSoft's Query Manager trying to write an expression. The original expression converted a date format into DD MON YY, here's the original expression that works:
CONVERT(VARCHAR(10), A.TERMINATION_DT, 103) AS [DD MON YY]
I need to add termination dates for a few people, manually (they're not termed yet, but will be, so I have to input it like this).
So I thought I could do a case statement:
(CASE WHEN B.EMPLID IN ('XXXXXX') THEN '2022-08-19' ELSE (CONVERT(VARCHAR(10), A.TERMINATION_DT, 103) AS [DD MON YY]) END)
When I input the above I get the following error:
A SQL error occurred. Please consult your system log for details.
Error in running query because of SQL Error, Code=8603,
Message=[Microsoft][ODBC Driver 13 for SQL Server][SQL
Server]Incorrect syntax near the keyword 'AS'. [Microsoft][ODBC Driver
13 for SQL Server][SQL Server]Incorrect syntax near 'PS_JOB'.
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax
nea란ᆌŪ (50,380)
Where am I going wrong?
The problem with your edit of the query is that you put AS [DD MON YY] statement, which sets the alias for the column, into the CASE statement.
It should be after the entire CASE statement.
Provided that the rest of the syntax is correct, it should be:
(CASE
WHEN B.EMPLID IN ('XXXXXX') THEN '2022-08-19'
ELSE CONVERT(VARCHAR(10), A.TERMINATION_DT, 103)
END) AS [DD MON YY]
Okay I figured it out. Not terribly difficult in the end.
(CASE WHEN B.EMPLID IN ('XXXXXX') THEN '2022-08-19' ELSE (CONVERT(VARCHAR(10), A.TERMINATION_DT, 103) ) END)

SQR - how to use FROM [dynamic table name} within BEGIN-SELECT?

I have to create an SQR that generates a list of EEIDs, if there were any changes to the Pension data in the past day. The SQR compiles and works perfectly when I hardcode in the table names.
However, when I tried using variables for the table names, I get a compile error
I've pasted the portion of SQR that I'm trying to fix
When I start using $tableName and $auditTableName as table variables, that's when I get the error and I'm not sure what is going wrong
Can anyone help?
Please and Thank You
!***************************
begin-procedure Process-Main
!***************************
let $tableName = 'PS_PENSION_PLAN'
let $auditTableName = 'PS_AUDIT_PENSION_PLN'
let $dummy-dyn-variable = ''
begin-SELECT DISTINCT
L.EMPLID
L.EMPL_RCD
do someProcName(&L.EMPLID, &L.EMPL_RCD)
FROM [$dummy-dyn-variable]
(
SELECT DISTINCT
PP.EMPLID,
PP.EMPL_RCD,
PP.EFFDT,
'1901-01-01 12:00:00' AS AUDIT_STAMP
FROM [$dummy-dyn-variable] [$tableName] PP
UNION
SELECT DISTINCT
A.EMPLID,
A.EMPL_RCD,
A.EFFDT,
A.AUDIT_STAMP
FROM [$dummy-dyn-variable] [$auditTableName] A
)L
WHERE DATEDIFF(DAY,CAST(L.AUDIT_STAMP AS DATE),SYSDATE) = 1
ORDER BY 1,2
end-SELECT
end-procedure
Edit:
does the UNION have anything to do with this?
I keep receiving is this error:
(SQR 5528) ODBC SQL dbdesc: SQLNumResultCols error 102 in cursor 1:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'FROM'.
(SQR 5528) ODBC SQL dbdesc: SQLNumResultCols error 8180 in cursor 1:
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
Edit2:
Ok, initial problem solved with [$dummy-dyn-variable], which led to the next problem with the DO command. I've updated the code above with DO someProcName(param_a, param_b)
I am now getting an error saying:
(SQR 2002) DO arguments do not match procedure's
Weird part, if I remove the dynamic table variables and hardcode the table names in the FROM section, then it compiles properly without errors. This makes me believe that the error is not related to my someProcName (maybe?)
am I missing something here?

Make SQLite abort on first error (and sing songs)

I wanted to name this post Make SQLite abort on first error but StackOverflow's AI overlords decided it doesn't fit their conception of intelligent human behavior. For the record, I was googling exactly that, but perhaps even Google AI considered my question unworthy and didn't bother to help me. Mods, feel free to change the title according to what your AI bosses desire (if you can figure it out).
I have this script
create if not exists table entries (
id integer primary key,
start datetime not null,
end datetime not null
);
delete from entries;
insert into entries values (1, '2018-08-01 10:00', '2018-08-01 15:00');
insert into entries values (2, '2018-08-01 17:00', '2018-08-01 20:00');
insert into entries values (1, '2018-08-02 19:00', '2018-08-02 00:00');
insert into entries values (1, '2018-08-03 00:00', '2018-08-03 04:00');
insert into entries values (1, '2018-08-03 14:00', '2018-08-03 18:00');
There is a mistake in create statement. When I run the script I get
% sqlite3 db.sqlite3 <ddl.sql
Error: near line 1: near "if": syntax error
Error: near line 7: no such table: entries
Error: near line 8: no such table: entries
Error: near line 9: no such table: entries
Error: near line 10: no such table: entries
Error: near line 11: no such table: entries
Error: near line 12: no such table: entries
How do I make SQLite exit executing the script on first error it encounters? I'm looking for equivalent of set -e in Bash.
From the documentation, it looks like you can turn on the dot command .bail.
.bail on|off Stop after hitting an error. Default OFF
See also - O'Reilly Using Sqlite
Edit
To exit, you can use the .exit dot command.

MySQL server version for the right syntax group by datetime

I have been trying to solve the issue to group by datetime for sometimes but I still can't resolve it.
Please give some advice on what wrong with my syntax?
Sytnax error message i get:-
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 ' DATE_FORMAT(mdatetime,'%Y-%m-%d') AS 'Date',count(*) AS 'Total Registrants' fro' at line 1
select $regdate AS 'Date',count(*) AS 'Total Registrants' from $regTable where $regdate <= '$date' group by $regdate order by $regdate DESC LIMIT 10

Execute Immediate with multiple SQL Statements

Here is my PL/SQL.
execute immediate '
create table Alex_Test2(col1 varchar2(100));
/
drop table Alex_Test2;
/
';
In the dynamic SQL, a table is created and then dropped immediately. The funny thing is that the table is successfully created and dropped but I got error.
Error starting at line 1 in command:
execute immediate '
Error report:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "; END;" when expecting one of the following:
:= . ( # % ;
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Error starting at line 6 in command:
'
Error report:
Unknown Command
The SQL statements actually typed by user. I cannot avoid the symbols like ; and /. How can I fixed this problem? Or how can I bypass this error?
However, I still need to keep the log. I expect the log is just
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Thanks!
You are unable to manipulate the query string before executing it? If you don't have the ability to do that then what do you have the ability to do?
Sounds like you just need to do a find and replace on the query string before running it.

Resources