SQL Table Error Magento - php

This is very odd, anyone have an answer for why this gives an error?
------------------------------------------------------ --
--
-- Table structure for table `mg_cataloginventory_stock`
--
CREATE TABLE IF NOT EXISTS `mg_cataloginventory_stock` (
`stock_id` SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Stock Id',
`stock_name` VARCHAR( 255 ) DEFAULT NULL COMMENT 'Stock Name',
PRIMARY KEY ( `stock_id` )
) ENGINE = INNODB DEFAULT CHARSET = utf8 COMMENT = 'Cataloginventory Stock';
MySQL said: Documentation
#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 '--------------------------------------------------------
--
-- Table structu' at line 1

It appears that your SQL comment syntax is incorrect.
From a “-- ” sequence to the end of the line. In MySQL, the “-- ” (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on).
It should be something like this:
-- ------------------------------------------------------
--
-- Table structure for table `mg_cataloginventory_stock`
--

Related

oci_execute(): OCI_SUCCESS_WITH_INFO: ORA-24344 using a trigger/sequence to auto increment an oracle table error

I'm using a sequence and trigger to essentially auto increment a column in a table, however I'm getting an error - ORA-24344: success with compilation error.
I was using this post: How to create id with AUTO_INCREMENT on Oracle? and it worked successfully for two other tables w/ auto increment I made, but there must be something in here I'm not familiar with causing an error.
More edits: Thanks to Polppan we've established that this likely isn't an Oracle issue, rather an OCI with PHP issue. I'm using:
oci_execute($sql);
And as mentioned here (again, thanks Polppan for that link), there's a bit of an issue between EOL characters and oci_execute. It was 11 years ago, so I don't know if that's been patched or not, and I did try his solution but it didn't help. Does anyone know if there are other issues with oci_execute and creating triggers?
Creating the table: (works)
CREATE TABLE RT_documents (
documentID INT NOT NULL,
reviewID varchar2(20) NOT NULL,
file_location CLOB NOT NULL,
version NUMBER(*,3) NOT NULL,
CONSTRAINT RT_documents_pk PRIMARY KEY (documentID)
)
Creating the sequence: (works)
CREATE SEQUENCE rt_documents_seq
Creating/replacing trigger: (doesn't work)
CREATE OR REPLACE TRIGGER rt_documents_bir
BEFORE INSERT ON RT_documents
FOR EACH ROW
BEGIN
SELECT RT_documents_seq.NEXTVAL
INTO :new.documentID
FROM dual;
END;
EDIT: Exact error message as requested - (Note, I'm executing these query-by-query using OCI/Oracle in PHP. PHP tag added just in case, but pretty sure this is an oracle syntax error or something).
Error:
Notice: oci_execute(): OCI_SUCCESS_WITH_INFO: ORA-24344: success with
compilation error in (...)
-I can successfully execute the first two queries, and double checked and the table is there so it worked properly.
Trigger doesn't understand new.id as id doesn't exist in RT_documents table.
Your trigger should be
CREATE OR REPLACE TRIGGER rt_documents_bir
BEFORE INSERT
ON RT_documents
FOR EACH ROW
BEGIN
SELECT RT_documents_seq.NEXTVAL INTO :new.documentID FROM DUAL;
END;
Update
SELECT * FROM v$version;
Oracle Database 10g Enterprise Edition
CREATE TABLE RT_documents
(
documentID INT NOT NULL,
reviewID VARCHAR2 (20) NOT NULL,
file_location CLOB NOT NULL,
version NUMBER (*, 3) NOT NULL,
CONSTRAINT RT_documents_pk PRIMARY KEY (documentID)
);
Table created.
CREATE SEQUENCE rt_documents_seq;
Sequence created.
CREATE OR REPLACE TRIGGER rt_documents_bir
BEFORE INSERT
ON RT_documents
FOR EACH ROW
BEGIN
SELECT RT_documents_seq.NEXTVAL INTO :new.documentID FROM DUAL;
END;
/
Trigger created.
INSERT INTO RT_documents (reviewID, file_location, version)
VALUES ('test', 'test', 1);
1 row created.
SELECT * FROM RT_documents;
DOCUMENTID REVIEWID FILE_LOCATION
VERSION
---------- -------------------- -------------------------------------------
-------------------------------- ----------
1 test test
1
Thanks to Polppan.
The solution was removing the EOL characters. (I did try this but had, without realising, removed the semi-colons, which caused the same error code)
This was a PHP error after all. Using oci_execute, you must remove EOL characters in triggers:
$sql = "CREATE OR REPLACE TRIGGER ......."; //shortened for easy reading
$sql = str_replace(chr(13),'',$sql);
$sql = str_replace(chr(10),'',$sql);
oci_execute($sql);

how to delete a database in mysql to export a database with same name?

Until yesterday everything was fine.
Everything I did i create a .sql file of a database and reinstall wamp server and i gave a password for localhost. After restarting the PC I was able to access the database without having importing it.
But today there is no table inside the database.
So i tried to export it but failed since the name already exists. So I rename it and tried to export and getting the error message:
Error
SQL query:
-- --------------------------------------------------------
--
-- Table structure for table `cgpa_details`
--
CREATE TABLE IF NOT EXISTS `cgpa_details` (
`cgpa_id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`usn` VARCHAR( 7 ) NOT NULL ,
`sem1` FLOAT NOT NULL ,
`sem2` FLOAT NOT NULL ,
`sem3` FLOAT NOT NULL ,
`sem4` FLOAT NOT NULL ,
`sem5` FLOAT NOT NULL ,
`sem6` FLOAT NOT NULL ,
`sem7` FLOAT NOT NULL ,
`sem8` FLOAT NOT NULL ,
PRIMARY KEY ( `cgpa_id` ) ,
UNIQUE KEY `usn` ( `usn` )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =4;
MySQL said: Documentation
1813 - Tablespace for table 'ssitdashboard.cgpa_details' exists. Please DISCARD the tablespace before IMPORT.
restart mysql.
ALTER TABLE cgpa_details DISCARD TABLESPACE;
EDIT:
DROP TABLESPACE 'ssitdashboard.cgpa_details'
Also check this link: http://mysqlhints.blogspot.ro/2008/10/fixing-innodb-import-tablespace-error.html

mySQL error: You have an error in your SQL syntax (ENGINE=MyISAM)

At the first time I got such error, I realize the problem was similar to this question > Error #1064 in mysql So I changed the TYPE=MyISAM on my code to ENGINE=MyISAM.
But even after the changing, I encountered similar error. It says,
mySQL error: 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 '(14),
PRIMARY KEY (id)
) ENGINE=M' at line 7.
I thought changing to ENGINE=MyISAM would fix the error, but it doesn't. What should I do?
Here is my code:
$queries[] = "CREATE TABLE IF NOT EXISTS {$prefix}conversationlog (
id int(11) NOT NULL auto_increment,
input text default '',
response text default '',
thatresponse text default '',
uid varchar(255) default NULL,
enteredtime timestamp(14),
PRIMARY KEY (id)
) ENGINE=MyISAM";
The error is at the (14), not ENGINE=MyISAM. The TIMESTAMP type does not take a size; it's always timestamp-sized.

mysql error 'TYPE=MyISAM'

Below query I'm executing in Ubuntu 12, MySQL 5.1 version and receiving error as mentioned:
CREATE TABLE mantis_config_table (
config_id VARCHAR(64) NOT NULL,
project_id INTEGER NOT NULL DEFAULT 0,
user_id INTEGER NOT NULL DEFAULT 0,
access_reqd INTEGER DEFAULT 0,
type INTEGER DEFAULT 90,
value LONGTEXT NOT NULL,
PRIMARY KEY (config_id, project_id, user_id)
) TYPE=MyISAM;
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 'TYPE=MyISAM' at line 9
Can anyone suggest what's wrong?
Replace
TYPE=MyISAM
with
ENGINE=MyISAM
The problem was "TYPE=MyISAM" which should be "ENGINE=MyISAM" as per MySQL version updates - a simple search / replace has fix it.
Do not use the keyword TYPE anymore. Use ENGINE instead.
TYPE keyword is depreciated (since 5.0) and not supported in MySQL5.5
CREATE TABLE mantis_config_table
(
...
)
ENGINE = MyISAM;
^^^^^^--------------------- HERE
In newer MySQL Versions its:
ENGINE=MyISAM
here the tutorial (MySQL)
Use ENGINE instead of TYPE
ENGINE = MYISAM ;

Symfony: creating invalid MySQL code?

I'm reading the Symfony documentation (Practical Symfony), and I finished creating the SQL code with propel.
But when i try to
$ symfony propel:insert-sql
the MySQL complains with:
#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 'Type=InnoDB' at line 7
Snippet of the produced MySQL code:
CREATE TABLE `jobeet_category` (
`id` INTEGER NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 255 ) ,
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `jobeet_category_U_1` ( `name` )
) TYPE = InnoDB;
So the problem is TYPE = InnoDB;, but I don't understand why did propel produce invalid code.
I followed all the instructions in the book, I'm not sure what could be the problem - maybe the MySQL version I have?
Edit: I found my answer. http://zippykid.com/2010/05/symfony-mysql5-5-error/
I'm pretty sure it should be ENGINE = InnoDB instead of type.

Categories