6 #import <Foundation/Foundation.h>
7 #import <EOAccess/EOAccess.h>
8 #import <NGExtensions/NGExtensions.h>
14 #define ALL_RECORDS @"/home/znek/all-BALI.plist"
17 int main(int argc, char **argv, char **env) {
18 NSAutoreleasePool *pool;
21 EOAdaptorContext *ctx;
23 NSDictionary *conDict;
25 pool = [[NSAutoreleasePool alloc] init];
26 #if LIB_FOUNDATION_LIBRARY
27 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
30 conDict = [NSDictionary dictionaryWithContentsOfFile:@"connection.plist"];
31 NSLog(@"condict is %@", conDict);
33 if ((a = [EOAdaptor adaptorWithName:@"PostgreSQL72"]) == nil) {
34 NSLog(@"found no PostgreSQL adaptor ..");
38 NSLog(@"got adaptor %@", a);
39 [a setConnectionDictionary:conDict];
40 NSLog(@"got adaptor with condict %@", a);
42 ctx = [a createAdaptorContext];
43 ch = [ctx createAdaptorChannel];
45 m = [[EOModel alloc] initWithContentsOfFile:@"inserts.eomodel"];
48 [a setConnectionDictionary:conDict];
52 NSLog(@"opening channel ..");
54 [ch setDebugEnabled:YES];
56 if ([ch openChannel]) {
57 NSLog(@"channel is open");
60 if ([ctx beginTransaction]) {
61 NSLog(@"began tx ..");
65 NSAutoreleasePool *lpool = [[NSAutoreleasePool alloc] init];
74 if([ctx beginTransaction]) {
75 expr = @"DROP TABLE SOGo_test";
77 if([ch evaluateExpression:expr]) {
78 attrs = [ch describeResults];
79 NSLog(@"results: %@", attrs);
82 if([ctx commitTransaction]) {
83 NSLog(@"DROP'ed table - committed.");
85 NSLog(@"couldn't commit DROP TABLE!");
91 NSLog(@"DROP table aborted - %@", [localException reason]);
99 if([ctx beginTransaction]) {
100 expr = @"CREATE TABLE SOGo_test (c_id INT PRIMARY KEY, c_dir VARCHAR(255) NOT NULL, c_cn VARCHAR(40) NOT NULL, c_mailto VARCHAR(120) NOT NULL);";
101 if([ch evaluateExpression:expr]) {
102 if([ctx commitTransaction]) {
103 NSLog(@"CREATE TABLE - committed");
105 NSLog(@"couldn't commit CREATE TABLE!");
112 fprintf(stderr, "exception: %s\n", [[localException description] cString]);
121 NSLog(@"committing tx ..");
122 if ([ctx commitTransaction])
123 NSLog(@" could commit.");
125 NSLog(@" commit failed.");
129 NSLog(@"closing channel ..");