Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

MySql Triggers

  • javsilcas
  • javsilcas's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #122758 by javsilcas
MySql Triggers was created by javsilcas
Hello all,

I'm trying to copy the final data from a survey (whenever it is completed) to another table into the same database. This is to update some dashboards in a page. I'm doing this with a Mysql server and a trigger so that when the "Insert" occurs it copies the information onto the new table. I'm using this code to test:

Create trigger inserta after insert on lime_survey_672142
for each row

insert into lime_respuestas(Q1,Q2,Q3)
values (new.answerfield,'Q2','Q3')

The trigger is created succesfully, but when I run the survey it shows me this message:

No se guardó

Ha ocurrido un error inesperado y sus respuestas no han podido ser guardadas.

Sus respuestas no se han perdido, han sido enviadas por correo electrónico al administrador del cuestionario para su posterior incorporación a nuestra base de datos.

I've changed the line:

values (new.answerfield,'Q2','Q3')

to

values ('Q1','Q2','Q3')

in order to see the results and it works great.

What could be happenning?

I really appreciate your help and comments.

Thank you very much.
Javier SIlva
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 9 months ago #122759 by gabrieljenik
Replied by gabrieljenik on topic MySql Triggers
Hola Javier,

Por lo que comentas, el error parece estar en "new.answerfield".
Ese campo existe en la tabla? Creo que no es un campo de las tablas de respuestas.
Por otro lado, intenta utilizar la palabra NEW en mayuscula.

Saludos!

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.
  • javsilcas
  • javsilcas's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #122761 by javsilcas
Replied by javsilcas on topic MySql Triggers
Gracias por tus comentarios Gabriel.

El campo existe en la tabla e intenté utilizar la palabra "new" en mayúsculas. El trigger se genera bien de ambas formas, sin embargo cuando lanzo el cuestionario me manda el error descrito arriba a través de la forma "new.campo". Esa es la forma que busco ya que pretendo actualizar otra tabla con las respuestas de cada participante. ¿Alguna sugerencia?.

Muchas gracias por tu atención.
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 9 months ago #122774 by gabrieljenik
Replied by gabrieljenik on topic MySql Triggers
Disculpa que parezca reiterativo, pero el campo answerfield existe en la tabla lime_survey_672142?
Acabo de fijarme en una de mis encuestas y no lo veo.

NEW contiene campos de la tabla origen solamente, no de la tabla destino "lime_respuestas"

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose