4
** Copyright (c) 2007 Inverse groupe conseil inc. and Ludovic Marcotte
6
** Author: Ludovic Marcotte <ludovic@inverse.ca>
8
** This library is free software; you can redistribute it and/or
9
** modify it under the terms of the GNU Lesser General Public
10
** License as published by the Free Software Foundation; either
11
** version 2.1 of the License, or (at your option) any later version.
13
** This library is distributed in the hope that it will be useful,
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
** Lesser General Public License for more details.
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with this library; if not, write to the Free Software
20
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
#import "EOAttribute+Oracle.h"
25
@implementation EOAttribute (OracleExtensions)
27
+ (id) attributeWithOracleType: (ub2) theType
28
name: (text *) theName
29
length: (ub4) theLength
35
attr = [[EOAttribute alloc] init];
36
s = AUTORELEASE([[NSString alloc] initWithBytes: theName length: theLength encoding: NSASCIIStringEncoding]);
38
// Oracle returns us the column names using uppercase strings.
39
// We change that to avoid lameness in other parts of GDL.
40
s = [s lowercaseString];
43
[attr setColumnName: s];
44
[attr setWidth: (unsigned)theWidth];
49
[attr setExternalType: @"VARCHAR2"];
50
[attr setValueClassName: @"NSString"];
53
[attr setExternalType: @"CLOB"];
54
[attr setValueClassName: @"NSString"];
57
// char[7] that contains the date and time but no time zone information.
58
[attr setExternalType: @"DATE"];
59
[attr setValueClassName: @"NSDate"];
62
[attr setExternalType: @"INTEGER"];
63
[attr setValueClassName: @"NSNumber"];
64
[attr setValueType: @"d"];
68
[attr setExternalType: @"NUMBER"];
69
[attr setValueClassName: @"NSNumber"];
70
[attr setValueType: @"d"];
73
[attr setExternalType: @"STRING"];
74
[attr setValueClassName: @"NSString"];
77
[attr setExternalType: @"TIMESTAMP"];
78
[attr setValueClassName: @"NSCalendarDate"];
80
case SQLT_TIMESTAMP_TZ:
81
[attr setExternalType: @"TIMESTAMP WITH TIME ZONE"];
82
[attr setValueClassName: @"NSCalendarDate"];
84
case SQLT_TIMESTAMP_LTZ:
85
[attr setExternalType: @"TIMESTAMP WITH LOCAL TIME ZONE"];
86
[attr setValueClassName: @"NSCalendarDate"];
89
NSLog(@"Unsupported type! %d\n", theType);
92
return AUTORELEASE(attr);