How to run the SQL Script - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

psaunders
Posts: 30
Joined: Fri Oct 29, 2010 3:08 pm

How to run the SQL Script

Hi,

I have the following SQL script.

DELIMITER //

DROP TRIGGER IF EXISTS Trig_report_declaration_image_Before_Insert //
CREATE TRIGGER Trig_report_declaration_image_Before_Insert
BEFORE INSERT ON report_declaration
FOR EACH ROW
BEGIN
DECLARE ATabletID VARCHAR(45);

SELECT TabletID INTO ATabletID
FROM tablet;

SET new.TabletID = IFNULL(ATabletID, "");
END//

DROP TRIGGER IF EXISTS Trig_report_template_config_Before_Insert//
CREATE TRIGGER Trig_report_template_config_Before_Insert
BEFORE INSERT ON report_template_config
FOR EACH ROW
BEGIN
DECLARE ATabletID VARCHAR(45);

SELECT TabletID INTO ATabletID
FROM tablet;

SET new.TabletID = IFNULL(ATabletID, "");
END//

DROP TRIGGER IF EXISTS Trig_systemvalues_Before_Insert//
CREATE TRIGGER Trig_systemvalues_Before_Insert
BEFORE INSERT ON systemvalues
FOR EACH ROW
BEGIN
DECLARE ATabletID VARCHAR(45);

SELECT TabletID INTO ATabletID
FROM tablet;

SET new.TabletID = IFNULL(ATabletID, "");
END//

When i try to run it using AI i get the following error. {SQL_ERROR}: {SQL_STATE: 42000} you have an error in your SQL syntax....near 'DELIMITER //

DROP TRIGGER IF EXISTS Trig_report_declaration_image_before...' at line 1.

I am able to run the script in MySQL Query browsers and am using the following setting in AI

Statement Separator is BLANK
Strip Comment is unchecked
Run SQL Script at install
Script Condition 1
In case of error : Abort Installation
No Script replacements.

Any help is appreciated.
Thanks in advance
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to run the SQL Script

Hello,

I am afraid I could not find any keyword named "DELIMITER" in the SQL documentation. Perhaps that is causing the issue.
Also, I am not sure what "//" does in your script. But I'm not that familiar with SQL, so these might be valid keywords / valid syntax.

What I can say is your script's syntax doesn't seem to be compatible with your SQL server.

Try removing the "//" delimiter, and also make sure you have the ";" delimiter in the "Statement Separator" field instead of leaving it blank.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
psaunders
Posts: 30
Joined: Fri Oct 29, 2010 3:08 pm

Re: How to run the SQL Script

Hi,

Thanks for the reply. The DELIMITER keyword is used to separate multiline statements. It is used in MySQL http://dev.mysql.com/doc/refman/5.0/en/ ... edure.html to create tirggers and procedures.

I am not sure how the following will run

DROP TRIGGER IF EXISTS Trig_report_declaration_image_Before_Insert;
CREATE TRIGGER Trig_report_declaration_image_Before_Insert
BEFORE INSERT ON report_declaration
FOR EACH ROW
BEGIN
DECLARE ATabletID VARCHAR(45);

SELECT TabletID INTO ATabletID
FROM tablet;

SET new.TabletID = IFNULL(ATabletID, "");
END;

as

"CREATE TRIGGER Trig_report_declaration_image_Before_Insert
BEFORE INSERT ON report_declaration
FOR EACH ROW
BEGIN
DECLARE ATabletID VARCHAR(45);
"

is not a single statement. However, i will try what you suggested and report back

Thanks

Return to “Common Problems”