以下 SQL 代码在 SQLite 管理器和其他 SQLite 系统中运行良好,但是当我在 Titanium 中使用它时,我得到一个Uncaught SyntaxError: Unexpected String".如果我的语法错误,应该如何为 Titanium 编码?
The following SQL code works fine in SQLite Manager and in other SQLite systems, however when I use it in Titanium I get an "Uncaught SyntaxError: Unexpected String." If my syntax is wrong, how should it be coded for Titanium?
SELECT Date, Content
FROM MYDATABASE
WHERE strftime('%m%d', Date) = strftime('%m%d', date('now'))
您是否将您的表称为 MYDATABASE?您是否正在逐步调试调试器并确认 var rs = db.execute("SELECT Date, Content FROM MYDATABASE WHERE strftime('%m%d', date) = strftime('%m%d', date('现在'))");
Did you call your table MYDATABASE? Are you stepping through the debugger and confirming that var rs = db.execute("SELECT Date, Content FROM MYDATABASE WHERE strftime('%m%d', date) = strftime('%m%d', date('now')) ");
在我的 Titanium Mobile 项目中,我首先定义了数据库:
In my Titanium Mobile project I first defined the database:
var db = Ti.Database.open('myDb');
db.execute('CREATE TABLE IF NOT EXISTS [MYDATABASE](id INTEGER PRIMARY KEY AUTOINCREMENT, Date DATE, Content TEXT)');
db.close();
然后我从函数调用中执行了这段代码
I then executed this code from a function call
var db = Ti.Database.open('myDb');
var myresult = db.execute("INSERT INTO MYDATABASE(Date, Content) VALUES (date('now'), '12345')");
myresult = db.execute("SELECT Date, Content FROM MYDATABASE WHERE strftime('%m%d', Date) = strftime('%m%s', date('now')) ");
Ti.API.info('myresult: ' + myresult.fieldByName('Content'));
此代码在调试窗口中成功返回 myresult: 12345.您可能需要向我们提供源代码的重要部分,以便我们可以看到代码的流程.给我们碎片是行不通的.
This code returns myresult: 12345 in the debug window successfully for me. You probably need to provide us with a significant part of the source code so we can see the flow of the code. Giving us pieces isn't working.
不幸的是,我不得不在另一台计算机上进行测试,希望在这里重新输入不会出错"
Unfortunately, I had to test this from another computer and hopefully didn't make any errors re-typing it here"
这篇关于SQLite Titanium 语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Apache Spark 中连接到 SQLiteConnect to SQLite in Apache Spark(在 Apache Spark 中连接到 SQLite)
Kafka JDBC 源连接器时间戳模式对 sqlite3 失败Kafka JDBC source connector time stamp mode failing for sqlite3(Kafka JDBC 源连接器时间戳模式对 sqlite3 失败)
Adobe Air:为什么 SQLStatement 的 getResult().data 为空?Adobe Air: why SQLStatement#39;s getResult().data is null?(Adobe Air:为什么 SQLStatement 的 getResult().data 为空?)
SQLite 和 FlexSQLite and Flex(SQLite 和 Flex)
Adobe Air:将 sqlite 的结果 [object Object] 转换为 StriAdobe Air: convert sqlite#39;s result [object Object] to String?(Adobe Air:将 sqlite 的结果 [object Object] 转换为 String?)
sqlite &flex - 如果不存在则插入?sqlite amp; flex - insert into if not exists?(sqlite amp;flex - 如果不存在则插入?)