Changeset error-handling,2.1.3 for error-handling/doc/documentation.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
-
error-handling/doc/documentation.html (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
error-handling/doc/documentation.html
r2.1.2 r2.1.3 5 5 <title>Plain-odbc Documentation</title> 6 6 </head> 7 8 7 <body> 9 8 <h1>plain-odbc documentation</h1> … … 12 11 This is the version of plain-odbc which I am using right now. 13 12 The API could stand some improvements, currently it is rather 14 simple. Hopefully it suffices for many uses. I thought I make 15 the current version available before I make my mind up about 16 another API. 13 simple. But I think it is good enough for many uses. 14 A higher level API is not a goal. 17 15 </p> 18 16 <p> … … 21 19 ODBC documentation from Microsoft</a>. 22 20 </p> 23 <h2>Platforms, not up to date</h2> 24 <p> 25 Plain-odbc uses CFFI to interface to the odbc libaries. I have tested it on 26 Windows LispWorks Personal Edition (4.4) and 27 CLISP 2.38. I am too lazy to download the new version of 28 an "Allegro CL Trial Edition", but I am confident that this should also work. 29 On Windows ODBC connections to Oracle and SQL-Server work. 30 On Linux plain-odbc has been tested with CLISP and MySQL. 31 </p> 32 21 <h3>Platforms</h3> 22 <p> 23 Plain-odbc uses CFFI to interface to the ODBC libaries. 24 The development platform ist clisp on Windows XP. 25 On this system accessing Microsoft SQL-Server, Oracle 10g and MySQL 5.0 works. 26 I do not expect big problems with other databases which have an ODBC driver. 27 If there are problems they can also originate from the implementation of the 28 ODBC driver, e.g. MyODBC does not support out parameters. 29 At one time plain-odbc worked on Windows with LispWorks Personal Edition (4.4) 30 and Allegro. 31 On Linux it worked with CMUCL and MySQL. Since the interface to the ODBC library 32 is done with 33 CFFI, plain-odbc should still with on these platforms/systems. 34 </p> 35 <p> 36 David Owen made the necessary changes to the code to make it run on 37 64-bit Linux CMUCL and MySQL. 38 </p> 33 39 <h2> Using plain-odbc, Examples </h2> 34 You must load plain-odbc into lisp. plain-odbc is an asdf module,40 You must load plain-odbc into lisp. Plain-odbc is an asdf module, 35 41 so you need asdf. Make sure that asdf is able to find CFFI and plain-odbc. 36 42 <pre>(asdf:oos 'asdf:load-op :plain-odbc) … … 75 81 Oracle does not really have integer columns, integer is just a short hand 76 82 for <tt>number(37,0)</tt>, and in a query this is returned as decimal. 77 And plain-odbc converts decimals to doubles. 83 And plain-odbc converts decimals to doubles. 78 84 <pre> 79 85 [9]> (exec-update *con* "update test1 set y=? where x=?" "text2" 1) … … 223 229 actual parameter. 224 230 </p> 231 <p><b>Note: MySql does not support out and in/out parameters. There are no 232 return parameters. A citation from the documentation of MySql:</b> 233 </p> 234 <p><em> 235 For programs written in a language that provides a MySQL interface, there is no native method for directly retrieving the results of OUT or INOUT parameters from CALL statements. To get the parameter values, pass user-defined variables to the procedure in the CALL statement and then execute a SELECT statement to produce a result set containing the variable values. The following example illustrates the technique (without error checking) for a stored procedure p1 that has two OUT parameters. 236 </em><tt><br> 237 mysql_query(mysql, "CALL p1(@param1, @param2)");<br> 238 mysql_query(mysql, "SELECT @param1, @param2");<br> 239 result = mysql_store_result(mysql);<br> 240 row = mysql_fetch_row(result);<br> 241 mysql_free_result(result);<br> 242 </tt> 243 244 245 </p> 246 225 247 <p> 226 248 The function <tt>prepare-statement</tt> is called with the parameters … … 236 258 Currently the only parameter is the maximal length parameter for 237 259 the string and binary (= Oracle's raw) datatypes. Instead of a list for 238 a parameter description only the name of the parameter type can be given. This is239 equivalent to a list with two elements: the symbol and the direction <tt>:in</tt>.260 a parameter description only the name of the parameter type can be given. 261 This is equivalent to a list with two elements: the symbol and the direction <tt>:in</tt>. 240 262 The following parameter types ares supported: 241 263 </p> … … 337 359 the value returns true then the value is passed as :date. Of course 338 360 <tt>*date-datatype-to-universal-time*</tt> must be able to convert 339 the value universal time.361 the value to universal time. 340 362 </ul> 341 363 … … 387 409 <p> 388 410 <br><b>[Function]</b><br> 389 <tt>connect-sql-server <i>server database</i> &optional <i>user password</i></tt><br>390 Connect to sql server named <i>server</i>, the initial database is <i>database</i>.391 If <i>user</i> and <i>password</i> are supplied the connection is made with sql server392 authentication, if the parameters are not supplied then the connection is made with393 integrated security. The name of the template odbc datasource for this function is394 <tt>default-sql-server-dsn</tt>.395 </p>396 <p>411 <tt>connect-sql-server <i>server database</i> &optional <i>user password</i></tt><br> 412 Connect to sql server named <i>server</i>, the initial database is <i>database</i>. 413 If <i>user</i> and <i>password</i> are supplied the connection is made with sql server 414 authentication, if the parameters are not supplied then the connection is made with 415 integrated security. The name of the template odbc datasource for this function is 416 <tt>default-sql-server-dsn</tt>. 417 </p> 418 <p> 397 419 <br><b>[Function]</b><br> 398 420 <tt>connect-oracle <i>server user password</i></tt><br> … … 401 423 <tt>default-oracle-dsn</tt>. 402 424 </p> 403 <p>404 <br><b>[Function]</b><br>405 <tt>connect-access <i>filename</i></tt><br>425 <p> 426 <br><b>[Function]</b><br> 427 <tt>connect-access <i>filename</i></tt><br> 406 428 Connect to the access database (a .mdb file) with name filename. 407 429 The name of the template odbc datasource for this function is 408 430 <tt>default-access-dsn</tt>. 409 431 </p> 410 432 <p> 433 <br><b>[Function]</b><br> 434 <tt>connect-mysql <i>server database user password</i></tt><br> 435 Connect to the MySql server on <i>server</i> connecting as user 436 <i>user</i> with password <i>password</i>. The default database is 437 <i>database</i>. If database is <tt>NIL</tt> no database is chosen. 438 The name of the template odbc datasource for this function is 439 <tt>default-mysql-dsn</tt>. 440 </p> 441 411 442 <h3>Working with Connections</h3> 412 443 <p> … … 428 459 If a column is a LOB (BLOB or CLOB) then the data is retrieved 429 460 with the ODBC function SQLGetData. This has the consequence that 430 th rfollowing columns must also be retrieved with SQLGetData,461 the following columns must also be retrieved with SQLGetData, 431 462 otherwise an error is raised by the driver. 432 463 Retrieving the following columns via … … 440 471 But be carefull with the conversion format (1.23 vs. 1,23). 441 472 </p> 473 <p> 474 <br><b>[Function]</b><br> 475 <tt>exec-query*<i>connection sqlstring parameters</i></tt><br> 476 The same as <tt>exec-query</tt>, but the ODBC parameters are passed as a list. 477 </p> 442 478 <p> 443 479 <br><b>[Function]</b><br> … … 447 483 list of parameter descriptions. 448 484 </p> 485 <p> 486 <br><b>[Function]</b><br> 487 <tt>exec-update*<i>connection sqlstring parameters</i></tt><br> 488 The same as <tt>exec-update</tt>, but the ODBC parameters are passed as a list. 489 </p> 449 490 <p> 450 491 <br><b>[Function]</b><br> … … 453 494 <i>parameters</i> is a list of parameter descriptions. 454 495 Returns the list of out and in-out parameters. 455 </p> 496 </p> 497 <p> 498 <br><b>[Function]</b><br> 499 <tt>exec-command*<i>connection sqlstring parameters</i></tt><br> 500 The same as <tt>exec-command</tt>, but the ODBC parameters are passed as a list. 501 </p> 502 456 503 <p> 457 504 <br><b>NOTE</b><br> … … 460 507 One can execute a select statement with <tt>exec-update</tt> and 461 508 <tt>exec-command</tt>. But the command for <tt>exec-query</tt> 462 must return a resultset. 463 </p> 509 must return a resultset. The following functions offers the functionality 510 of all three functions: 511 </p> 512 <br><b>[Function]</b><br> 513 <tt>exec-sql <i>connection sqlstring &rest parameters</i></tt></br> 514 Execute an sql statement (select, dml or stored procedure call) on <i>connection</i> 515 with sql <i>sqlstring</i>. <i>parameters</i> is a list of parameter descriptions. 516 This function returns three values 517 <ul> 518 <li> the number of affected records, i.e. what is normally returend by 519 <tt>exec-update</tt>.</li> 520 <li> the list of the resultsets, each resultset is a list of two elements: 521 the list of rows and a list of the column names.</li> 522 <li>the list of returned parameters</li> 523 </ul> 524 </p> 525 <p> 526 <br><b>[Function]</b><br> 527 <tt>exec-sql*<i>connection sqlstring parameters</i></tt><br> 528 The same as <tt>exec-sql</tt>, but the ODBC parameters are passed as a list. 529 </p> 530 464 531 <P> 465 532 <br><b>[Function]</b><br>
Note: See TracChangeset
for help on using the changeset viewer.
