当我尝试利用我在这里创建的 SQLite 数据库时,Android 崩溃了
当我尝试创建动态列时出现以下错误。我认为这是合法的,但显然 Android 和 SQLite 不喜欢这样。我确信我错过了一些简单的事情,但我就是想不起来。
错误消息是:没有这样的列:sundayResult:,编译时:
CREATE TABLE DAYSUSED(
_id INTEGER PRIMARY KEY autoincrement,
sunday INTEGER NOT NULL,
monday INTEGER NOT NULL,
tuesday INTEGER NOT NULL,
wednesday INTEGER NOT NULL,
thursday INTEGER NOT NULL,
friday INTEGER NOT NULL,
saturday INTEGER NOT NULL);
SELECT _id
, volume_level
, vibrate
, CASE WHEN sunday = 1 THEN 'Sun' ELSE ' ' END AS sundayResult
, CASE WHEN monday = 1 THEN 'Mon' ELSE ' ' END AS mondayResult
, CASE WHEN tuesday = 1 THEN 'Tues' ELSE ' ' END AS tuesdayResult
, CASE WHEN wednesday = 1 THEN 'Wed' ELSE ' ' END AS wednesdayResult
, CASE WHEN thursday = 1 THEN 'Thur' ELSE ' ' END AS thursdayResult
, CASE WHEN friday = 1 THEN 'Fri' ELSE ' ' END AS fridayResult
, CASE WHEN saturday = 1 THEN 'Sat' ELSE ' ' END AS saturdayResult
, sundayResult || ' ' || mondayResult || ' ' || tuesdayResult || ' ' || wednesdayResult || ' ' || thursdayResult || ' ' || fridayResult || ' ' || saturdayResult || ' ' AS days_of_week
FROM DAYSUSED
如果我直接调用实际列,则最后一行将起作用,例如:
, sunday || ' ' ||
而不是我当前拥有的列:
, sundayResult || ' ' ||
我已经查看了所有内容,但没有知道还可以尝试什么,因为我真的很想更改光标的数据。
谢谢, 凯莉
I get the following error when I attempt to create dynamic columns. I thought this was legit, but apparently Android and SQLite don't like this. I'm sure I'm missing something simple, but I just can't recall.
Error message is: no such column: sundayResult: , while compiling:
CREATE TABLE DAYSUSED(
_id INTEGER PRIMARY KEY autoincrement,
sunday INTEGER NOT NULL,
monday INTEGER NOT NULL,
tuesday INTEGER NOT NULL,
wednesday INTEGER NOT NULL,
thursday INTEGER NOT NULL,
friday INTEGER NOT NULL,
saturday INTEGER NOT NULL);
SELECT _id
, volume_level
, vibrate
, CASE WHEN sunday = 1 THEN 'Sun' ELSE ' ' END AS sundayResult
, CASE WHEN monday = 1 THEN 'Mon' ELSE ' ' END AS mondayResult
, CASE WHEN tuesday = 1 THEN 'Tues' ELSE ' ' END AS tuesdayResult
, CASE WHEN wednesday = 1 THEN 'Wed' ELSE ' ' END AS wednesdayResult
, CASE WHEN thursday = 1 THEN 'Thur' ELSE ' ' END AS thursdayResult
, CASE WHEN friday = 1 THEN 'Fri' ELSE ' ' END AS fridayResult
, CASE WHEN saturday = 1 THEN 'Sat' ELSE ' ' END AS saturdayResult
, sundayResult || ' ' || mondayResult || ' ' || tuesdayResult || ' ' || wednesdayResult || ' ' || thursdayResult || ' ' || fridayResult || ' ' || saturdayResult || ' ' AS days_of_week
FROM DAYSUSED
The last line will work if I do a direct call to the actual columns like:
, sunday || ' ' ||
instead of what I have currently which is:
, sundayResult || ' ' ||
I've looked all over and don't know what else to try, as I'd really like to alter the data for the cursor.
Thanks,
Kelly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
sundayResult 只是一个别名,您不能在同一查询中使用它。你需要这样的东西。如果volume_level和vibrate来自不同的表,则将其与子查询“days”连接
sundayResult is just an alias and you cannot use it into the same query. You need something like this. If volume_level and vibrate are coming from different table, then join it with subquery "days"