Changeset 64-bit,2.1.3 for 64-bit/doc/notes.html
- Timestamp:
- 02/03/2008 08:14:49 PM (18 years ago)
- revision id:
- svn-v3-trunk1:1c22b0a8-4d0b-0410-a296-af6a2e6f35e3:plain-odbc%2Ftrunk:10
- File:
-
- 1 edited
-
64-bit/doc/notes.html (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
64-bit/doc/notes.html
r2.1.2 r2.1.3 1 1 <html> 2 <!-- ;;;-*- Mode: HTML; -*- --> 2 <!-- -*- Mode: HTML; -*- --> 3 <head> 4 <title>Notes on Plain-Odbc</title> 5 </head> 6 <body> 3 7 <h3>Notes</h3> 4 8 <p> This documents contains some observations and pitfalls encountered 9 when using different drivers and databases. 10 </p> 5 11 <h4> driver-connect </h4> 6 12 Using driver-connect one does not have to create an ODBC datasource for every … … 40 46 41 47 42 <h4> performance s</h4>48 <h4> performance </h4> 43 49 It seems that with clisp storing and retrieving C datatypes from memory take a lot time. 44 50 This should be possible without consing, maybe I have to change my clisp FFC module. … … 90 96 MYODBC (3.51?) does not return unicode character data as datatype SQL_WVARCHAR. If for SQL_VARCHAR data the return datatype is set to SQLWCHAR, the length in the indicator is 0. It seems that the buffer is also empty (= #x000000000 ...). There is some talk about better support for unicode in another version (3.52?). 91 97 98 <h4> 99 <p> 100 More Information about Oracle ODBC Driver</h4> 101 There is documentation for the Oracle ODBC driver, it is at</p> 102 <tt> 103 Oracle® Database Administrator's Reference<br> 104 10g Release 2 (10.2) for UNIX-Based Operating Systems<br> 105 Part Number B15658-05<br> 106 G Using Oracle ODBC Driver<br> 107 </tt> 108 or better under the link 109 <a href="http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b15658/app_odbc.htm"> G Using Oracle ODBC Driver</a>, but this can change any time. 110 92 111 <h4>Oracle 9.2 and unicode</h4> 93 112 <p> 94 I can not make Oracle return unicode. I am using a 9.2 DB I have created a nchar column which is a unicode datatype for 9.2. 113 I can not make Oracle return unicode. I am using a 9.2 DB I have created a nchar column which is a 114 unicode datatype for 9.2. 95 115 <p> 96 116 I am using the oracle driver. There is a workaround tab where one can force the driver to … … 99 119 Only selecting from NLS_SESSION_PARAMETERS returns a 16bit charcater. 100 120 Or do I have this problem since NLS_CHARACTERSET=WE8ISO8859P15? 121 <h4> Oracle 10gR2 and unicode</h4> 122 It works now (with Oracle driver!): 123 <pre> 124 [13]> (schar (caar (exec-query *con* "select nCHR(232) from dual")) 0) 125 126 #\LATIN_SMALL_LETTER_E_WITH_GRAVE 127 [14]> 128 129 [16]> (char-code (schar (caar (exec-query *con* "select ? from dual" (list (string (code-char 1234)) :unicode-string)) ) 0)) 130 131 1234 132 </pre> 133 101 134 102 135 <h4>Microsoft ODBC driver for Oracle</h4> … … 107 140 108 141 <h4>Oracle and ref cursors</h4> 109 This is easy with the oracle odbc driver and an 9.2 database. 142 This works with 9.2 and 10g and 10gR2. Make sure that the ODBC datasource is 143 configured correctly. On the "Oracle ODBC Driver Configuration" window check the 144 checkbox with label "Enable Result Sets".<br> 110 145 Example: 111 146 <pre> … … 127 162 (with-prepared-statement (stm con 128 163 "{call test99_pkg.test_cursor(?,?)}" 129 '( (:string :in )))164 '(:string :in )) 130 165 (let ((str "just a string")) 131 (exec-prepared-query stm (list str)))) 132 </pre> 133 Note that the cursor parameter must be declared in/out. If a parameter ist supplied for the cursor parameter, it still works. <em>This needs more investigations.</em> 134 135 <h4>Oracle TIMESTAMP datatype in 9.2, 10g</h4> 166 (exec-prepared-query stm str))) 167 </pre> 168 Note that the cursor parameter must be declared in/out. 169 If a parameter ist supplied for the cursor parameter, it still works. 170 </em> 171 <em>This needs more investigations.</em> 172 173 <h4>Oracle TIMESTAMP datatype</h4> 174 <h5> 9.2, 10g</h4> 136 175 Windows: For the Oracle-Driver, queries on TIMESTAMP columns return SQL_NULL_TYPE. Normally this would be retrieved 137 176 as String. But the program coredumps at the first fetch. … … 140 179 At least we prevent the coredump of the Oracle driver.<br> 141 180 I am pretty sure that this is a driver bug, Microsoft Access coredumps as well in similar situations. 142 143 144 <h4>MYSQL</h4> 181 <h5>10g R2</h5> 182 It works now, a timestamp column is retrieved as SQL_TIMESTAMP. 183 Of course the sub second precision is not supported. 184 185 <h4>MySQL</h4> 145 186 This is not one would expect! 146 187 <pre> 147 mysql> create view bla as select date_add('2007-8-1',interval 1 day) as a;188 MySQL> create view bla as select date_add('2007-8-1',interval 1 day) as a; 148 189 Query OK, 0 rows affected (0.01 sec) 149 190 150 mysql> desc bla191 MySQL> desc bla 151 192 -> ; 152 193 +-------+---------------+------+-----+---------+-------+ … … 159 200 how to do it right: 160 201 <pre> 161 mysql> create view bla2 as select date_add(cast('2007-8-1' as datetime),interval 1 day) as a;202 MySQL> create view bla2 as select date_add(cast('2007-8-1' as datetime),interval 1 day) as a; 162 203 Query OK, 0 rows affected (0.00 sec) 163 204 164 mysql> desc bla2;205 MySQL> desc bla2; 165 206 +-------+----------+------+-----+---------+-------+ 166 207 | Field | Type | Null | Key | Default | Extra | … … 179 220 server settings: 180 221 <pre> 181 mysql> select cast(cast('12345678901' as decimal) as char) as a, cast(cast('1234567890' as decimal) as char) as b;222 MySQL> select cast(cast('12345678901' as decimal) as char) as a, cast(cast('1234567890' as decimal) as char) as b; 182 223 +------------+------------+ 183 224 | a | b | … … 191 232 Division by zero is handled, but only for an insert: 192 233 <pre> 193 mysql> set @a=1;234 MySQL> set @a=1; 194 235 Query OK, 0 rows affected (0.00 sec) 195 236 196 mysql> set @b=0;237 MySQL> set @b=0; 197 238 Query OK, 0 rows affected (0.00 sec) 198 239 199 mysql> select @a/@b;240 MySQL> select @a/@b; 200 241 +-------+ 201 242 | @a/@b | … … 205 246 1 row in set, 1 warning (0.00 sec) 206 247 207 mysql> insert into blu select @a/@b;248 MySQL> insert into blu select @a/@b; 208 249 ERROR 1365 (22012): Division by 0 209 250 </pre> 210 251 252 <h5>Handling of numbers</h5> 253 <pre> 254 [130]> (exec-query *con* "select cast(1.5e0/3.9e0 as char(200)) as a") 255 256 (("0.38461538461538")) ; 257 ("a") 258 [131]> (exec-query *con* "select cast(cast(1.5e0/3.9e0 as decimal(40,20)) as char(200)) as a") 259 260 (("0.38461538461538460000")) ; 261 ("a") 262 </pre> 263 In clisp on x86 I get: 264 <pre> 265 [132]> (/ 1.5d0 3.9d0) 266 267 0.38461538461538464d0 268 </pre> 269 With sql server I get the same value, as with clisp. 270 <p> 271 And another example : 272 <pre> 273 MySQL> select 1e14/7e0,1e14/7e0-14285714285714; 274 +----------------+-------------------------+ 275 | 1e14/7e0 | 1e14/7e0-14285714285714 | 276 +----------------+-------------------------+ 277 | 14285714285714 | 0.28515625 | 278 +----------------+-------------------------+ 279 1 row in set (0.00 sec) 280 </pre> 281 The decimal expansion of 1/7 is periodic, so the digits 0.285 are correct. Thus 282 MySQL uses the precision of double, but does not return all digits. 283 284 <h3>Parameters</h3> 285 <p> 286 As mentioned in the documentation, MySQL does not support out and in/out 287 parameters for sql statements. As the documentation of MySQL suggest 288 one should declare variables, pass them as parameters to the stored 289 procedures. After the procedure call one get there contents with a select 290 statement, example: <tt>select @param1 as param1,@param2 as param2</tt>. 291 292 </p> 293 <p> 294 The problem with variables on MySQL is that one can only set them. It is 295 not possible to declare a datatype for them. 296 Another option is to select the parameters directly in the stored procedure. 297 Thus instead of having out or in/out parameters, the procedure returns 298 return values as a result set. Note that <tt>exec-query<tt> accepts parameters 299 and can return more than one result set. One example, assume 300 <tt>*con*</tt> is a MySQL connection. 301 <pre> 302 [33]> (exec-command *con* " 303 create procedure test99(a1 varchar(200),b1 int,c1 date) 304 begin 305 declare a2 varchar(200); 306 declare b2 int; 307 declare c2 date; 308 set a2=concat(a1,'x'); 309 set b2=b1+3; 310 set c2=c1+ interval 1 day; 311 select a2 as a2,b2 as b2, c2 as c2; 312 end;") 313 314 315 [34]> (exec-query *con* "call test99(?,?,?)" "abc" 316 (list 12 :integer) (list (encode-universal-time 12 3 5 12 11 2007) :date)) 317 318 (("abcx" 15 3403897200)) ; 319 ("a2" "b2" "c2") 320 [35]> 321 </pre> 322 </body> 211 323 </html>
Note: See TracChangeset
for help on using the changeset viewer.
