1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
int intObject;
char charObject[255];
char varCharObject[255];
float floatObject;
for ( i = 1; i < (numCols + 1); i++ ) {
NSLog(@"We got a field of type: %d", dbcoltype(sybConn, i));
switch (dbcoltype(sybConn, i)) {
case SYBINT4:
NSLog(@"This wil be address of our intObject: %d", &intObject);
NSLog(@"The length of this intObject is: %d", dbdatlen(sybConn, i));
intObject = *((DBINT *)dbdata(sybConn, i));
/* Add the INT value to the array */
[record addObject:[NSNumber numberWithInt:intObject]];
NSLog(@"Adding INT value: %d", intObject);
break;
case SYBCHAR:
/* Copy the data from the buffer */
NSLog(@"This wil be address of our charObject: %d", &charObject);
strncpy(charObject, (char *)dbdata(sybConn, i), (int)dbdatlen(sybConn, i));
/* Add the terminating null character */
charObject[dbdatlen(sybConn, i)] = '\0';
/* Add the charObject to the Array */
[record addObject:[self stringWithUTF8CString:charObject]];
NSLog(@"Adding NSString value %s", charObject);
break;
case SYBVARCHAR:
/* Copy the data from the buffer */
strncpy(varCharObject, (char *)dbdata(sybConn, i), (int)dbdatlen(sybConn, i));
/* Add the terminating null character */
charObject[dbdatlen(sybConn, i)] = '\0';
/* Add the charObject to the Array */
[record addObject:[self stringWithUTF8CString:varCharObject]];
NSLog(@"Adding NSString value %s", varCharObject);
break;
default:
return NULL;
break;
}
|