gpt4 book ai didi

ios - iPhone sdk(fmdb 包装器)中的 SQLITE 错误

转载 作者:行者123 更新时间:2023-11-29 04:51:31 29 4
gpt4 key购买 nike

我在 sqlite 包装器方法中遇到问题。我已经定义了以下函数及其显示错误。我无法解决它。我所有的尝试都是为了交换数据​​库中的行。它在 sqlite 管理器(firefox 插件)中运行良好,仅使用 sql 语句。但这里显示了一个错误,所以我假设我定义函数的方式可能是错误的..有人可以稍微说明一下这个问题,这样有帮助吗?

提前致谢

//这就是我在数据库中定义函数的方式

-(NSMutableArray*)extractActivitytest:(int)pri
{
[db beginTransaction];
NSString* tSqlString = [NSString stringWithFormat:@"select Activity_Name from Activity where Priority = %d", pri];
FMResultSet *tRecordSet = (FMResultSet*)[db executeQuery:tSqlString];
NSMutableArray *rowArray = [[NSMutableArray alloc] init];
while ([tRecordSet next])
{

[rowArray addObject:[tRecordSet stringForColumn:COLUMN_ACT]];

}
return [rowArray autorelease];
[db commit];

}

///我就是这样调用它的

 [long1  setTitle:[[[DBManager getInstance]extractActivitytest:1] objectAtIndex:0]  forState:UIControlStateNormal];
[long2 setTitle:[[[DBManager getInstance]extractActivitytest:2] objectAtIndex:0]forState:UIControlStateNormal];
[long3 setTitle:[[[DBManager getInstance]extractActivitytest:3] objectAtIndex:0] forState:UIControlStateNormal];
[long4 setTitle:[[[DBManager getInstance]extractActivitytest:4] objectAtIndex:0]forState:UIControlStateNormal];
[long5 setTitle:[[[DBManager getInstance]extractActivitytest:5] objectAtIndex:0] forState:UIControlStateNormal];
[long6 setTitle:[[[DBManager getInstance]extractActivitytest:6] objectAtIndex:0] forState:UIControlStateNormal];

//这是我遇到的错误

2012-01-06 14:03:20.387 MyDaily6[5657:207] Path= /Users/rega/Library/Application       Support/iPhone Simulator/4.3.2/Applications/5A554560-A01A-4F44-980E-CC200E037CFE/Documents/Goals.sqlite
2012-01-06 14:03:22.490 MyDaily6[5657:207] Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
2012-01-06 14:03:22.491 MyDaily6[5657:207] DB Query: BEGIN EXCLUSIVE TRANSACTION;
2012-01-06 14:03:22.491 MyDaily6[5657:207] Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
2012-01-06 14:03:22.492 MyDaily6[5657:207] DB Query: BEGIN EXCLUSIVE TRANSACTION;
2012-01-06 14:03:22.492 MyDaily6[5657:207] Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
2012-01-06 14:03:22.493 MyDaily6[5657:207] DB Query: BEGIN EXCLUSIVE TRANSACTION;
2012-01-06 14:03:22.493 MyDaily6[5657:207] Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
2012-01-06 14:03:22.494 MyDaily6[5657:207] DB Query: BEGIN EXCLUSIVE TRANSACTION;
2012-01-06 14:03:22.494 MyDaily6[5657:207] Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
2012-01-06 14:03:22.495 MyDaily6[5657:207] DB Query: BEGIN EXCLUSIVE TRANSACTION;

///另一个类似的函数给出相同的错误

-(void)moveupData:(int)value1:(int)value2
{
NSString *stringSQL = [NSString stringWithFormat:@" UPDATE Activity SET Priority = (CASE WHEN Priority = %d THEN %d WHEN Priority = %d THEN %d END) WHERE Priority IN (%d,%d)", value1, value2];
[db executeQuery:stringSQL];
[db commit];

}//这就是我的调用方式

[[DBManager getInstance]moveupData:moveUp :moveDown];

//我遇到错误

 MOVEDOWN = 42012-01-06 14:03:34.932 MyDaily6[5657:207] Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
2012-01-06 14:03:34.933 MyDaily6[5657:207] DB Query: COMMIT TRANSACTION;

最佳答案

您确定您的数据库已打开吗?你应该打电话

[db open]

并且,对于第二部分,如果您想写入数据库,则应该使用

[db executeUpdate:stringSQL];

希望对你有帮助!

关于ios - iPhone sdk(fmdb 包装器)中的 SQLITE 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8755382/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com