Sintax error for SQL condition

Hi guys,

What is the syntax for building a SQL with parameters in AppSutdio?

This syntax not work, see:

scl=Array(“SELECT * FROM Categorias_Demo WHERE codemp=?”, nCodEmp, ListaCat);

nCodEmp is a value for pass in the query, this case number 1

ListCat is the function that retrieves the data from the query and list in the listview

But the following error occurs:

Any idea for the problem?

Have a look in the docs:

http://wiki.nsbasic.com/Using_SQLite

sqlList[0]="INSERT INTO customerData (name,age,sales) VALUES ('Haley',16,121)"

Yes, and example for my query in “Using SQLite” is

sqlList[j]=[“SELECT * FROM customerData WHERE name=?”, “Customer” & Fix(Rnd * databaseSize), Random_Total]

And http://wiki.nsbasic.com/SQLite_made_Simple:

sqlList[0]=[“SELECT * FROM studentData WHERE name=?”, txtFind.value, nameFound]

My query is a SELECT command not a INSERT

But, not work, this example context no longer works.

An app that worked with the same query, now does not work anymore, and shows the same error.

Has anything changed in the new version of AppStudio?

is nCodeEmp a string or a number? It needs to be a string.

1 Like

nCodEmp is a number (integer) get the one table

I changed the query this way and it worked

sqlList[0]=[“SELECT * FROM Categorias_Demo WHERE codemp=” & nCodEmp & " ORDER BY categoria", [], ListaCat];

What I realized is that it is not accepting arguments passed in the function in the 2nd parameter, because the error message is that the 3rd function is not a function

Description statment SQL for wiki
The Sql statement is used to send a transaction (a list of SQL commands) to SQLite. Db is the reference returned by an SQLOpenDataBase function. sqlList is an array of strings containing SQL statements to execute, or an array of arrays. In the case of an array of arrays, each entry should be of the following form:

[sqlStatement, [args,] successCallback, errorCallback]

Look this [args,] ???

Your changed statement converts nCodEmp to a string, which is why it works. Try this:

scl=Array("SELECT * FROM Categorias_Demo WHERE codemp=?", nCodEmp & "", ListaCat);

1 Like

Thanks Leader for your orientation, its work!