Sintax error for SQL condition


#1

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?


#2

Have a look in the docs:

http://wiki.nsbasic.com/Using_SQLite

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


#3

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?


#4

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


#5

nCodEmp is a number (integer) get the one table


#6

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,] ???


#7

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);


#8

Thanks Leader for your orientation, its work!