Error installion Plugin with MS SQL Database on Windows

Error installion Plugin with MS SQL Database on Windows

by BMD Technik -
Number of replies: 1
Dear all,

When installion the plugin on 4.0.4 Moodle with MS SQL Database in background i got this error:

Debug-Info:  SQLState: 42000<br>

Error Code: 102<br>

Message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near 'qr'.<br>


UPDATE mdl_questionnaire_response qr INNER JOIN mdl_questionnaire_attempts qa ON qr.id = qa.rid SET qr.questionnaireid = qa.qid

[array (

)]

Error code: dmlwriteexception×Diese Systemnachricht ablehnen

Stack trace: 

line 489 of \lib\dml\moodle_database.php: dml_write_exception thrown

line 324 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()

line 431 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()

line 820 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()

line 736 of \mod\questionnaire\db\upgrade.php: call to sqlsrv_native_moodle_database->execute()

line 883 of \lib\upgradelib.php: call to xmldb_questionnaire_upgrade()

line 582 of \lib\upgradelib.php: call to upgrade_plugins_modules()

line 1935 of \lib\upgradelib.php: call to upgrade_plugins()

line 719 of \admin\index.php: call to upgrade_noncore()

Seems to be that the statement dont work on Microsoft SQL Server (Version 2019)

Can you help with this?


Average of ratings: -
In reply to BMD Technik

Re: Error installion Plugin with MS SQL Database on Windows

by BMD Technik -
i did following workaround:

running manuell with sql mgmt studio the right statement

UPDATE mdl_questionnaire_response qr INNER JOIN mdl_questionnaire_attempts qa ON qr.id = qa.rid SET qr.questionnaireid = qa.qid

insted of

UPDATE qr SET qr.questionnaireid = qa.qid FROM mdl_questionnaire_response qr INNER JOIN mdl_questionnaire_attempts qa ON qr.id = qa.rid;

inside the update.php disabled the part line 732 - 736

// Get all of the attempts records, and add the questionnaire id to the corresponding response record.
//$sql = 'UPDATE {questionnaire_response} qr ' .
// 'INNER JOIN {questionnaire_attempts} qa ON qr.id = qa.rid ' .
// 'SET qr.questionnaireid = qa.qid';
//$DB->execute($sql, []);

now i was able to install the plugin

can you please fix the statement in future release?

best regards