AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

UPDATE using AlaSQL #1375

Open debritto opened 3 years ago

debritto commented 3 years ago

I'm running AlaSQL using Google Apps Script successfully, I can even run Select with Join and other complex selects.

But I'm having problem to run a simple UPDATE statement like this:

function test_db(){

    var retorno1 = alasql("UPDATE Fatores SET Aspecto = `160-Ético` WHERE Substituicao = `INTEGRAÇÃO LOCAL`");

    Logger.log(retorno1);

}

When I try to run this function I receive this message:

TypeError: Cannot read property 'onupdatefns' of undefined
k.Update.compile    @ alasql.gs:29268
bi.dexec    @ alasql.gs:26084
bi.exec @ alasql.gs:26071
bi  @ alasql.gs:22
test_db @ Aspectos.gs:57

For the record I'm running this version of AlaSQL: AlaSQL v1.7.3-develop-0be167bcundefined

Below is an example of my table in Google Sheets:

Fator Substituicao Aspecto
ACOLHIMENTO INTEGRAÇÃO LOCAL 010-Numérico
ADAPTAÇÃO INTEGRAÇÃO LOCAL 010-Numérico
APOIO INTEGRAÇÃO LOCAL 010-Numérico
CAPACITAÇÃO EDUCAÇÃO 100-Conhecimento
CIDADE URBANIDADE 110-Social/Relacional
COMPARAÇÃO XENOFOBIA 110-Social/Relacional
COMUNHÃO INTEGRAÇÃO LOCAL 010-Numérico

Any help will be precious as I already spent hours trying to solve this!

gregja commented 3 years ago

Hi @debritto , Could it be a problem of character encoding, as a conflict with the character ` ? Did you try with that technique ?

function test_db(){
    const datas = ["160-Ético", "INTEGRAÇÃO LOCAL"];
    var retorno1 = alasql("UPDATE Fatores SET Aspecto = ? WHERE Substituicao = ?", datas); 
    Logger.log(retorno1);
}