Changeset error-handling,2.1.3 for error-handling/src/test/test-oracle.lisp
- 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
-
error-handling/src/test/test-oracle.lisp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
error-handling/src/test/test-oracle.lisp
r2.1.1 r2.1.3 15 15 ora-test6 16 16 ora-test7 17 #+ignore ;; unicode support does not work for oracle18 17 ora-test8 19 18 ora-test9 20 19 ora-test10 21 20 ora-test11 21 ora-test12 22 22 )) 23 23 (pprint sym) … … 39 39 t_number number, 40 40 t_char char(2000) , 41 t_varchar varchar(4000), 41 t_varchar varchar2(4000), 42 t_nvarchar NVARCHAR2(200), 42 43 t_date date, 43 44 t_raw raw(2000), 44 45 t_blob blob, 45 t_clob clob) 46 t_clob clob, 47 t_nclob nclob 48 ) 46 49 ") 47 50 51 52 53 (defun ora-drop-test-proc (con proc) 54 (unless (zerop (caar (exec-query con (format nil "select count(*) 55 from user_objects where object_name='~A'" proc)))) 56 (exec-command con (format nil "drop procedure ~A" proc)))) 57 58 (defun ora-drop-test-table (con proc) 59 (unless (zerop (caar (exec-query con (format nil "select count(*) 60 from user_objects where object_name='~A'" proc)))) 61 (exec-command con (format nil "drop table ~A" proc)))) 62 63 48 64 (defun oracle-type-test (con) 49 (if (not (zerop (caar (exec-query con "select count(*) from user_tables where table_name ='TYPE_TEST'")))) 50 (exec-command con "drop table type_test")) 65 (ora-drop-test-table con "TYPE_TEST") 51 66 (exec-command con *oracle-type_test-ddl*) 52 67 (exec-update con "insert into type_test (id) values(1)") 53 68 (exec-update con " 54 69 update type_test set 55 t_integer= 12345678901234 5677989,70 t_integer= 12345678901234, 56 71 t_number = 1.0/3.0, 57 72 t_char=rpad('1',1999), 58 t_varchar =lpad('1',3999), 59 t_date = sysdate, 73 t_varchar =lpad('1',39), 74 t_nvarchar = lpad(nchr(1234),200,nchr(1234)), 75 t_date = to_date('1.3.2005 12:23:14','dd.mm.yyyy hh24:mi:ss'), 60 76 t_raw =hextoraw('11223344556677889900') 61 77 where id =1") 62 (exec-query con "select * from type_test")63 78 (let ((stm (prepare-statement 64 con "update type_test set t_blob=?,t_clob=? where id =1"65 '(:blob :in) '(:clob :in) )))79 con "update type_test set t_blob=?,t_clob=?,t_nclob=? where id =1" 80 '(:blob :in) '(:clob :in) '(:UNICODE-CLOB :in)))) 66 81 (exec-prepared-update 67 82 stm ;; sizes were 100000 and 100001 68 83 (make-array 100000 :element-type '(unsigned-byte 8) :initial-element 33) 69 (make-string 1000001 :initial-element #\o))) 84 (make-string 1000001 :initial-element #\o) 85 (make-string 1234567 :initial-element (code-char 3217)))) 86 (let ((res (exec-query con " 87 select id,t_integer,t_number,t_char,t_varchar,t_date,t_raw, t_nvarchar from type_test where id=1"))) 88 (assert (= (length res) 1)) 89 (setf res (first res)) 90 (assert (equal (nth 0 res) 1d0)) 91 (assert (equal (nth 1 res) 12345678901234d0)) 92 (assert (equal (nth 2 res) (/ 1d0 3))) 93 ;; t_char is of type char and therefor has always length 2000, 94 ;; although we inserted a string of length 1999 95 (assert (equal (nth 3 res) 96 (let ((a (make-string 2000 :initial-element #\space))) 97 (setf (schar a 0) #\1) 98 a))) 99 (assert (equal (nth 4 res) 100 (let ((a (make-string 39 :initial-element #\space))) 101 (setf (schar a 38) #\1) 102 a))) 103 (assert (equal (nth 5 res) 104 (encode-universal-time 14 23 12 1 3 2005))) 105 (assert (equal (coerce (nth 6 res) 'list) 106 '(#x11 #x22 #x33 #x44 #x55 #x66 #x77 #x88 #x99 #x00))) 107 (assert (equal (nth 7 res) (make-string 200 :initial-element (code-char 1234)))) 108 (let ((a (caar (exec-query con "select t_blob from type_test where id =1")))) 109 (assert (equalp a (make-array 100000 :element-type '(unsigned-byte 8) :initial-element 33)))) 110 (let ((b (caar (exec-query con "select t_clob from type_test where id=1")))) 111 (assert (equal b (make-string 1000001 :initial-element #\o)))) 112 113 (let ((c (caar (exec-query con "select t_nclob from type_test where id=1")))) 114 (assert (equal c (make-string 1234567 :initial-element (code-char 3217)))))) 115 70 116 (commit con)) 71 72 73 74 (defun ora-drop-test-proc (con proc)75 (unless (zerop (caar (exec-query con (format nil "select count(*)76 from user_objects where object_name='~A'" proc))))77 (exec-command con (format nil "drop procedure ~A" proc))))78 79 117 80 118 (defun ora-test1 (con) … … 200 238 ;; works only with oracle 9 ? 201 239 ;; this does not work. mybe with the oracle odbc driver? 240 ;; it works with oracle 10gr2 202 241 (defun ora-test8 (con) 203 242 (ignore-errors (exec-command con "drop table testtab99")) … … 208 247 (exec-prepared-update stm 1 str)) 209 248 (let ((res (exec-query con "select txt from testtab99 where id =1"))) 210 (assert (equal (list str) res)))))249 (assert (equal (list str) (first res)))))) 211 250 212 251 … … 244 283 245 284 246 285 (defun ora-test12 (con) 286 (ora-drop-test-proc con "TEST99") 287 (exec-command con (fix13 "create procedure test99 (a in out nvarchar2 ,b in out nvarchar2) as 288 x nvarchar2(1000); 289 begin x:=a; a:=b; b:=x; end;")) 290 (with-prepared-statement (stm con "{call test99(?,?)}" 291 '(:unicode-string :inout) 292 '(:unicode-string :inout)) 293 (let ((str1 (make-funny-string 700 (coerce (list (code-char 2341) (code-char 2347) #\a) 'vector ) )) 294 (str2 (make-funny-string 900 (coerce (list (code-char 2341) (code-char 2347) #\a) 'vector )))) 295 296 (let ((res (exec-prepared-command stm str1 str2))) 297 (assert (equal res (list str2 str1))))))) 298 299 (defun ora-test13 (con) 300 (ora-drop-test-table con "TESTTAB99") 301 (exec-command con "create table testtab99 (x integer,y varchar2(200))") 302 (multiple-value-bind (rc res params) 303 ;; if columns x and y are set by triggers they can also be retrieved by this method 304 (exec-sql con "insert into testtab99 (x,y) values(?+12,?||'a') returning x,y into ?,?" 13 "a" '(nil :integer :out) '(nil :string :out) ) 305 (assert (= rc 1)) 306 (assert (equal res nil)) 307 (assert (equal (list 25 "aa") params))))
Note: See TracChangeset
for help on using the changeset viewer.
