Comments (7)
Sorry, but I can't even being to help you out on this, since there are so many things that could be going wrong.
I would suggest you add a bunch of logging to your classes, and make sure every input that you're giving to the various methods is exactly as you expect it to be. Either that, or break the problem down into the simplest possible example, and if there's a bug in that- we can start there.
from fmdb.
Hi, thanks for your patience. This is the insert statement I am using:
[fmdb beginTransaction];
[fmdb executeUpdate:@"INSERT INTO T_ANSWER (PATIENT_VISIT_ID, QUESTION_ID) VALUES (?, ?)", [_patientVisit patientVisitId], [_question questionId]];
[fmdb commit];
if ([fmdb hadError]) {
[fmdb close];
NSLog(@"db error");
return FALSE;
}
and then, to check, I execute a count(*) select, and it returns that 0 records are in the table!?
no errors returned executeUpdate returns true, and rc in the inner method is 0.. i don't know what is it.. i open the connection multiple times before the insert, but i close it everytime.. that's the only sketchy thing i have in the app right now..
but my other concern is it does not "insert" into the db location I have it writes to this one:
i open the database like this:
fmdb = [FMDatabase databaseWithPath: [[NSBundle mainBundle] pathForResource:@"database" ofType:@"db"]];
any thoughts? this is the first time i use inserts in the application using fmdb, been always manually inserting data while developing..
again, thank you VERY much for your support!
Isaac
from fmdb.
forget about "but my other concern is it does not "insert" into the db location I have it writes to this one:" because it actually inserts in the right database.. i just check that.
from fmdb.
Sorry, I'm not sure what to tell you. Unless you can provide for me a stripped down reproducible sample, there isn't anything I can do.
from fmdb.
FMDatabase * fmdb = [FMDatabase databaseWithPath: [[NSBundle mainBundle] pathForResource:@"ortho" ofType:@"db"]];
[fmdb setLogsErrors: TRUE];
[fmdb setTraceExecution: TRUE];
[fmdb open];
[fmdb beginTransaction];
[fmdb executeUpdate:@"INSERT INTO T_ANSWER (PATIENT_VISIT_ID, QUESTION_ID) VALUES (?, ?)", [NSNumber numberWithInt: 99], [NSNumber numberWithInt: 99]];
[fmdb commit];
if ([fmdb hadError]) {
[fmdb close];
NSLog(@"db error");
return;
}
FMResultSet * rs = [fmdb executeQuery:@"select count(*) from T_ANSWER where PATIENT_VISIT_ID = 99"];
if ([fmdb hadError]) {
NSLog(@"cannot execute clean_start check query");
return;
}
NSLog(@"count inserted = %d", [rs intForColumnIndex: 1]);
[fmdb close];
2012-01-04 22:29:53.867 Tests[4099:207] SessionCommandProcessorGHTestCase/testSimpleInsert
2012-01-04 22:29:58.983 Tests[4099:207] Re-running: SessionCommandProcessorGHTestCase/testSimpleInsert <GHTest: 0x4c25590>
2012-01-04 22:29:58.985 Tests[4099:207] <FMDatabase: 0x4c2f190> executeUpdate: BEGIN EXCLUSIVE TRANSACTION;
2012-01-04 22:29:58.986 Tests[4099:207] <FMDatabase: 0x4c2f190> executeUpdate: INSERT INTO T_ANSWER (PATIENT_VISIT_ID, QUESTION_ID) VALUES (?, ?)
2012-01-04 22:29:58.988 Tests[4099:207] obj: 99
2012-01-04 22:29:58.988 Tests[4099:207] obj: 99
2012-01-04 22:29:58.989 Tests[4099:207] <FMDatabase: 0x4c2f190> executeUpdate: COMMIT TRANSACTION;
2012-01-04 22:29:58.992 Tests[4099:207] <FMDatabase: 0x4c2f190> executeQuery: select count(*) from T_ANSWER where PATIENT_VISIT_ID = 99
2012-01-04 22:29:58.993 Tests[4099:207] count inserted = 0
2012-01-04 22:29:58.996 Tests[4099:207] SessionCommandProcessorGHTestCase/testSimpleInsert ✔ 0.01s
table:
CREATE TABLE T_ANSWER (
ANSWER_ID INTEGER PRIMARY KEY ASC AUTOINCREMENT,
PATIENT_VISIT_ID INTEGER NOT NULL,
QUESTION_ID INTEGER NOT NULL UNIQUE,
EFF_TS INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
EXP_TS INTEGER
)
weird!?
from fmdb.
Works ok for me (using this JSTalk script):
var dbPath = "/tmp/jstalk.sqlite";
var db = [JSTDatabase databaseWithPath:dbPath];
if (![db open]) {
print("Could not open database");
}
[db executeUpdate:"""CREATE TABLE T_ANSWER (
ANSWER_ID INTEGER PRIMARY KEY ASC AUTOINCREMENT,
PATIENT_VISIT_ID INTEGER NOT NULL,
QUESTION_ID INTEGER NOT NULL UNIQUE,
EFF_TS INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
EXP_TS INTEGER
)"""];
[db executeUpdate:"INSERT INTO T_ANSWER (PATIENT_VISIT_ID, QUESTION_ID) VALUES (?, ?)", [NSNumber numberWithInt:99], [NSNumber numberWithInt:99]];
var rs = [db executeQuery:"select * from T_ANSWER"];
while ([rs next]) {
print([rs resultDict]);
}
var rs = [db executeQuery:"select count(*) from T_ANSWER where PATIENT_VISIT_ID = 99"];
while ([rs next]) {
print("b: " + [rs stringForColumnIndex:0]);
}
{
"answer_id" = 1;
"eff_ts" = "2012-01-05 17:50:58";
"exp_ts" = "";
"patient_visit_id" = 99;
"question_id" = 99;
}
b: 1
from fmdb.
Thank you! I'll do my homework!
from fmdb.
Related Issues (20)
- Can the current version be used stably? HOT 3
- closing FMDB database HOT 11
- Support for visionOS HOT 6
- Apple Privacy Manifest HOT 9
- FMDB 2.7.8 is not published on cocoapods HOT 3
- I encountered an issue where using UPDATE fails to update, but using INSERT OR REPLACE doesn't. HOT 1
- 无法通过git clone下载到本地 HOT 2
- PrivacyInfo.xcprivacy file did not be exposed HOT 6
- FMDB 2.7.8 is not available on cocoapods HOT 2
- xcodebuild: xcodebuild: error: Found no destinations for the scheme 'FMDB' and action clean
- get CocoaPods back on the rails HOT 24
- backfill CocoaPods versions HOT 1
- XCFrameworks are not codesigned HOT 7
- UT Coverage HOT 2
- FMDB.podspec of tag 2.7.10 declares wrong version HOT 2
- The subspec 'SQLCipher' required privacy file location declaration HOT 1
- Can you publish new release 2.7.11 HOT 6
- re-enable standalone CocoaPods subspecs HOT 2
- FMDB w/SQLCipher and an App Clip HOT 6
- How to insert multiple rows in a single SQL? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fmdb.