This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / class / IBM.Data.DB2 / IBM.Data.DB2 / DB2Type.cs
1
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 // 
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 // 
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 using System;\r
23 \r
24 namespace IBM.Data.DB2\r
25 {\r
26         public enum DB2Type\r
27         {\r
28                 Invalid = 0,\r
29                 SmallInt = 1,\r
30                 Integer = 2,\r
31                 BigInt = 3,\r
32                 Real = 4,\r
33                 Double = 5,\r
34                 Float = 6,\r
35                 Decimal = 7,\r
36                 Numeric = 8,\r
37                 Date = 9,\r
38                 Time = 10,\r
39                 Timestamp = 11,\r
40                 Char = 12,\r
41                 VarChar = 13,\r
42                 LongVarChar = 14,\r
43                 Binary = 15,\r
44                 VarBinary = 16,\r
45                 LongVarBinary = 17,\r
46                 Graphic = 18,\r
47                 VarGraphic = 19,\r
48                 LongVarGraphic = 20,\r
49                 Clob = 21,\r
50                 Blob = 22,\r
51                 DbClob = 23,\r
52                 Datalink = 24,\r
53                 RowId = 25,\r
54                 XmlReader = 26,\r
55         }\r
56         public class DB2TypeConverter\r
57         {\r
58                 public static Type GetManagedType(int sql_type)\r
59                 {\r
60                         switch(sql_type)\r
61                         {\r
62                                 case DB2Constants.SQL_INTEGER:\r
63                                         return typeof(int);\r
64                                 case DB2Constants.SQL_SMALLINT:\r
65                                         return typeof(short);\r
66                                 case DB2Constants.SQL_BIGINT:\r
67                                         return typeof(long);\r
68                                 case DB2Constants.SQL_DOUBLE:\r
69                                         return typeof(double);\r
70                                 case DB2Constants.SQL_DECIMAL:\r
71                                         return typeof(decimal);\r
72                                 case DB2Constants.SQL_DATETIME:\r
73                                 case DB2Constants.SQL_TYPE_DATE:\r
74                                 case DB2Constants.SQL_TYPE_TIMESTAMP:\r
75                                         return typeof(DateTime);\r
76                                 case DB2Constants.SQL_TYPE_TIME:\r
77                                         return typeof(TimeSpan);\r
78                                 case DB2Constants.SQL_CHAR:\r
79                                 case DB2Constants.SQL_VARCHAR:\r
80                                 case DB2Constants.SQL_TYPE_CLOB:\r
81                                         return typeof(string);\r
82                                 case DB2Constants.SQL_TYPE_BLOB:\r
83                                 case DB2Constants.SQL_TYPE_BINARY:\r
84                                 case DB2Constants.SQL_LONGVARBINARY:\r
85                                 case DB2Constants.SQL_VARBINARY:\r
86                                         return typeof(byte[]);\r
87                         }\r
88                         throw new NotImplementedException("Unknown SQL type " + sql_type);\r
89                 }\r
90         }\r
91 }\r