//Main program
int main(int argc, char *argv[])
{
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("root");
db.setDatabaseName("test");
if(db.open())
{
create_tables_sql = "DELIMITER $$ \n\
CREATE PROCEDURE Fun() \n\
BEGIN \n\
SELECT * FROM test; \n\
END $$ \n\
DELIMITER ; ";
qDebug() << create_tables_sql;
if (!me.exec(create_tables_sql))
{
qDebug() << "Query exec problem";
; }
qDebug() << me.lastError(); //QSqlError(-1, "", "")
exit(1);
}
else
{
qDebug() << "Db not open";
exit(1);
}
return app.exec();
}
//Main program
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("root");
db.setDatabaseName("test");
if(db.open())
{
QString create_tables_sql;
create_tables_sql = "DELIMITER $$ \n\
CREATE PROCEDURE Fun() \n\
BEGIN \n\
SELECT * FROM test; \n\
END $$ \n\
DELIMITER ; ";
qDebug() << create_tables_sql;
QSqlQuery me;
if (!me.exec(create_tables_sql))
{
qDebug() << "Query exec problem";
; }
qDebug() << me.lastError(); //QSqlError(-1, "", "")
exit(1);
}
else
{
qDebug() << "Db not open";
exit(1);
}
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Query exec problem
QSqlError(1064, "QMYSQL: Unable to execute query", "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 'DELIMITER $$
CREATE PROCEDURE Fun()
BEGIN
SELECT * FROM test;
END $$
DELIMI' at line 1")
Bookmarks