1 /** SECTION END: CLEANUP **/2 3 /*
4 ** Implements RSMDA.getColumnTypeName
5 ** create a procedure that will query
6 ** spt_jdbc_datatype_info for the correct jdbc mapped datatype or
7 ** the datasource specific systable, to retrieve the correct type
8 ** or user defined datatype name, based on the parameters
9 ** @datatype = the protocol datatype value
10 ** @usrtype = the data source specifc user defined datatype value
11 */12 createproceduresp_sql_type_name13 @datatype tinyint,14 @usrtype smallint
15 as16 BEGIN17 18 if @@trancount = 0
19 begin20 set chained off21 end22 23 settransactionisolationlevel 1
24 25 /* this will make sure that all rows are sent even if
26 ** the client "set rowcount" is differect
27 */28 29 setrowcount 0
30 31 /* Special case for types numericn, decimaln, daten and timen.
32 ** They do not seem to have the correct mapping of usertype & datatype
33 */34 /* if type is decimaln(106) map to decimal(55)
35 * if type is numericn(108) map to numeric(63)
36 * if type is daten (123) map to date (49)
37 * if type is timen (147) map to time (51)
38 * if type is bigdatetimen (187) map to bigdatetime (189)
39 * if type is bigtimen (188) map to bigtime (190)
40 */41 if(@datatype= 108)42 begin43 select@datatype= 63
44 end45 elseif(@datatype= 106)46 begin47 select@datatype= 55
48 end49 elseif(@datatype= 123)50 begin51 select@datatype= 49
52 end53 elseif(@datatype= 147)54 begin55 select@datatype= 51
56 end57 elseif(@datatype= 187)58 begin59 select@datatype= 189
60 end61 elseif(@datatype= 188)62 begin63 select@datatype= 190
64 end65 66 67 /* if a usertype is greater than 100 that means it is a
68 * user defined datatype, and it needs to be reference in
69 * the datasource specific systype table. If they are
70 * user-defined numeric/decimal, then only use the usertype
71 * for the search criteria (see the note on SPECIAL CASE below)
72 * This is the fix for Bug 192969.
73 */74 if(@usrtype> 100)75 begin76 selectnamefromsystypes77 whereusertype=@usrtype78 end79 /* check if we have the special case of a usertype signaling
80 * UNICHAR (34) or UNIVARCHAR (35)
81 */82 elseif(@usrtype= 34 or@usrtype= 35)83 begin84 selectnamefromsystypes85 whereusertype=@usrtype86 end87 /* simply check spt_jdbc_datatype_info for
88 * the predefined jdbc mapping for the types
89 */90 else91 begin92 selectj.type_nameas name
93 fromsybsystemprocs.dbo.spt_jdbc_datatype_info j
94 wherej.ss_dtype=@datatype95 end96 END97
exec sp_procxmode 'sp_sql_type_name', 'AnyMode'
go
Grant Execute on sp_sql_type_name to public
go