00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _terimber_dbaccess_h_
00029 #define _terimber_dbaccess_h_
00030
00031 #include "ostypes.h"
00032 #include "dbtypes.h"
00033 #include "log.h"
00034
00037 class async_db_notify
00038 {
00039 public:
00041 virtual
00042 ~async_db_notify() {}
00043
00045 virtual
00046 void
00047 notify_async( bool noerrors,
00048 size_t ident
00049 ) = 0;
00050 };
00051
00054 class dbserver : public terimber_log_helper
00055 {
00056 public:
00058 virtual
00059 ~dbserver()
00060 {
00061 }
00062
00066 virtual
00067 size_t
00068 get_ident() const = 0;
00071 virtual
00072 bool
00073 is_ready() const = 0;
00075 virtual
00076 size_t
00077 get_code() const = 0;
00079 virtual
00080 const char*
00081 get_error() const = 0;
00082
00083
00085
00086
00090
00092 virtual
00093 bool
00094 connect( bool trusted_connection,
00095 const char* connect_string
00096 ) = 0;
00098 virtual
00099 bool
00100 disconnect() = 0;
00102 virtual
00103 bool
00104 start_transaction() = 0;
00106 virtual
00107 bool
00108 commit() = 0;
00110 virtual
00111 bool
00112 rollback() = 0;
00114 virtual
00115 bool
00116 is_connect() const = 0;
00118 virtual
00119 bool
00120 is_in_transaction() const = 0;
00122 virtual
00123 bool
00124 is_connect_alive() = 0;
00125
00126
00128
00129
00134 virtual
00135 bool
00136 resize_params( size_t size
00137 ) = 0;
00139 virtual
00140 size_t
00141 get_param_count() const = 0;
00143 virtual
00144 dbtypes
00145 get_param_type( size_t index
00146 ) const = 0;
00148 virtual
00149 db_param_type
00150 get_param_in_out(size_t index
00151 ) const = 0;
00153 virtual
00154 bool
00155 get_param_is_null(size_t index
00156 ) const = 0;
00157
00164 virtual
00165 bool
00166 get_param_as_bool(size_t index
00167 ) const = 0;
00170 virtual
00171 sb1_t
00172 get_param_as_char(size_t index
00173 ) const = 0;
00176 virtual
00177 ub1_t
00178 get_param_as_byte(size_t index
00179 ) const = 0;
00182 virtual
00183 sb2_t
00184 get_param_as_short(size_t index
00185 ) const = 0;
00188 virtual
00189 ub2_t
00190 get_param_as_word(size_t index
00191 ) const = 0;
00194 virtual
00195 sb4_t
00196 get_param_as_long(size_t index
00197 ) const = 0;
00200 virtual
00201 ub4_t
00202 get_param_as_dword(size_t index
00203 ) const = 0;
00206 virtual
00207 float
00208 get_param_as_float(size_t index
00209 ) const = 0;
00212 virtual
00213 double
00214 get_param_as_double(size_t index
00215 ) const = 0;
00218 virtual
00219 sb8_t
00220 get_param_as_long64(size_t index
00221 ) const = 0;
00224 virtual
00225 ub8_t
00226 get_param_as_dword64(size_t index
00227 ) const = 0;
00231 virtual
00232 bool
00233 get_param_as_guid(size_t index,
00234 guid_t& val
00235 ) const = 0;
00239 virtual
00240 const char*
00241 get_param_as_numeric(size_t index,
00242 char delimeter
00243 ) const = 0;
00247 virtual
00248 const char*
00249 get_param_as_decimal(size_t index,
00250 char delimeter
00251 ) const = 0;
00255 virtual
00256 bool
00257 get_param_as_date(size_t index,
00258 ub4_t& year,
00259 ub1_t& month,
00260 ub1_t& day,
00261 ub1_t& hour,
00262 ub1_t& minute,
00263 ub1_t& second,
00264 ub2_t& millisec,
00265 ub1_t& wday,
00266 ub2_t& yday
00267 ) const = 0;
00271 virtual
00272 const char*
00273 get_param_as_string(size_t index
00274 ) const = 0;
00278 virtual
00279 const wchar_t*
00280 get_param_as_wstring(size_t index
00281 ) const = 0;
00284 virtual
00285 const ub1_t*
00286 get_param_as_binary(size_t index,
00287 size_t& len
00288 ) const = 0;
00292 virtual
00293 const ub1_t*
00294 get_param_as_binary_ptr(size_t index
00295 ) const = 0;
00297 virtual
00298 bool
00299 set_param_as_null(size_t index,
00300 db_param_type in_out,
00301 dbtypes type
00302 ) = 0;
00304 virtual
00305 bool
00306 set_param_as_bool(size_t index,
00307 db_param_type in_out,
00308 bool val
00309 ) = 0;
00311 virtual
00312 bool
00313 set_param_as_char(size_t index,
00314 db_param_type in_out,
00315 sb1_t val
00316 ) = 0;
00318 virtual
00319 bool
00320 set_param_as_byte(size_t index,
00321 db_param_type in_out,
00322 ub1_t val
00323 ) = 0;
00325 virtual
00326 bool
00327 set_param_as_short(size_t index,
00328 db_param_type in_out,
00329 sb2_t val
00330 ) = 0;
00332 virtual
00333 bool
00334 set_param_as_word(size_t index,
00335 db_param_type in_out,
00336 ub2_t val
00337 ) = 0;
00339 virtual
00340 bool
00341 set_param_as_long(size_t index,
00342 db_param_type in_out,
00343 sb4_t val
00344 ) = 0;
00346 virtual
00347 bool
00348 set_param_as_dword(size_t index,
00349 db_param_type in_out,
00350 ub4_t val
00351 ) = 0;
00353 virtual
00354 bool
00355 set_param_as_float(size_t index,
00356 db_param_type in_out,
00357 float val
00358 ) = 0;
00360 virtual
00361 bool
00362 set_param_as_double(size_t index,
00363 db_param_type in_out,
00364 double val
00365 ) = 0;
00367 virtual
00368 bool
00369 set_param_as_long64(size_t index,
00370 db_param_type in_out,
00371 sb8_t val
00372 ) = 0;
00374 virtual
00375 bool
00376 set_param_as_dword64(size_t index,
00377 db_param_type in_out,
00378 ub8_t val
00379 ) = 0;
00381 virtual
00382 bool
00383 set_param_as_guid(size_t index,
00384 db_param_type in_out,
00385 const guid_t& val
00386 ) = 0;
00387
00393 virtual
00394 bool
00395 set_param_as_numeric(size_t index,
00396 db_param_type in_out,
00397 const char* val,
00398 char delimeter
00399 ) = 0;
00401 virtual
00402 bool
00403 set_param_as_decimal(size_t index,
00404 db_param_type in_out,
00405 const char* val,
00406 char delimeter
00407 ) = 0;
00409 virtual
00410 bool
00411 set_param_as_date(size_t index,
00412 db_param_type in_out,
00413 ub4_t year,
00414 ub1_t month,
00415 ub1_t day,
00416 ub1_t hour,
00417 ub1_t minute,
00418 ub1_t second,
00419 ub2_t millisec
00420 ) = 0;
00424 virtual
00425 bool
00426 set_param_as_string(size_t index,
00427 db_param_type in_out,
00428 const char* val,
00429 size_t len,
00430 size_t max_len = 0
00431 ) = 0;
00437 virtual
00438 bool
00439 set_param_as_string_ptr(size_t index,
00440 const char* val
00441 ) = 0;
00442
00446 virtual
00447 bool
00448 set_param_as_wstring(size_t index,
00449 db_param_type in_out,
00450 const wchar_t* val,
00451 size_t len,
00452 size_t max_len = 0
00453 ) = 0;
00459 virtual
00460 bool
00461 set_param_as_wstring_ptr(size_t index,
00462 const wchar_t* val
00463 ) = 0;
00467 virtual
00468 bool
00469 set_param_as_binary(size_t index,
00470 db_param_type in_out,
00471 const ub1_t* val,
00472 size_t len,
00473 size_t max_len = 0
00474 ) = 0;
00483 virtual
00484 bool
00485 set_param_as_binary_ptr(size_t index,
00486 const ub1_t* val
00487 ) = 0;
00488
00490
00492 virtual
00493 size_t
00494 get_column_count() const = 0;
00496 virtual
00497 dbtypes
00498 get_column_type(size_t index
00499 ) const = 0;
00501 virtual
00502 const char*
00503 get_column_name(size_t index
00504 ) const = 0;
00506 virtual
00507 bool
00508 get_column_nullable(size_t index
00509 ) const = 0;
00511 virtual
00512 size_t
00513 get_column_scale(size_t index
00514 ) const = 0;
00516 virtual
00517 size_t
00518 get_column_precision(size_t index
00519 ) const = 0;
00521 virtual
00522 size_t
00523 get_column_max_length(size_t index
00524 ) const = 0;
00525
00526
00528
00529
00531 virtual
00532 size_t
00533 get_row_count() const = 0;
00535 virtual
00536 void
00537 reset() const = 0;
00539 virtual
00540 bool
00541 next() const = 0;
00543 virtual
00544 bool
00545 prev() const = 0;
00546
00553 virtual
00554 bool
00555 get_value_is_null(size_t index
00556 ) const = 0;
00558 virtual
00559 bool
00560 get_value_as_bool(size_t index
00561 ) const = 0;
00562 virtual
00564 sb1_t
00565 get_value_as_char(size_t index
00566 ) const = 0;
00568 virtual
00569 ub1_t
00570 get_value_as_byte(size_t index
00571 ) const = 0;
00573 virtual
00574 sb2_t
00575 get_value_as_short(size_t index
00576 ) const = 0;
00578 virtual
00579 ub2_t
00580 get_value_as_word(size_t index
00581 ) const = 0;
00583 virtual
00584 sb4_t
00585 get_value_as_long(size_t index
00586 ) const = 0;
00588 virtual
00589 ub4_t
00590 get_value_as_dword(size_t index
00591 ) const = 0;
00593 virtual
00594 float
00595 get_value_as_float(size_t index
00596 ) const = 0;
00598 virtual
00599 double
00600 get_value_as_double(size_t index
00601 ) const = 0;
00603 virtual
00604 sb8_t
00605 get_value_as_long64(size_t index
00606 ) const = 0;
00608 virtual
00609 ub8_t
00610 get_value_as_dword64(size_t index
00611 ) const = 0;
00612
00614 virtual
00615 bool
00616 get_value_as_guid(size_t index,
00617 guid_t& val
00618 ) const = 0;
00621 virtual
00622 const char*
00623 get_value_as_numeric(size_t index,
00624 char delimeter
00625 ) const = 0;
00628 virtual
00629 const char*
00630 get_value_as_decimal(size_t index,
00631 char delimeter
00632 ) const = 0;
00635 virtual
00636 bool
00637 get_value_as_date(size_t index,
00638 ub4_t& year,
00639 ub1_t& month,
00640 ub1_t& day,
00641 ub1_t& hour,
00642 ub1_t& minute,
00643 ub1_t& second,
00644 ub2_t& millisec,
00645 ub1_t& wday,
00646 ub2_t& yday
00647 ) const = 0;
00650 virtual
00651 const char*
00652 get_value_as_string(size_t index
00653 ) const = 0;
00655 virtual
00656 const wchar_t*
00657 get_value_as_wstring(size_t index
00658 ) const = 0;
00659
00662 virtual
00663 const ub1_t*
00664 get_value_as_binary(size_t index,
00665 size_t& len
00666 ) const = 0;
00672 virtual
00673 const ub1_t*
00674 get_value_as_binary_ptr(size_t index
00675 ) const = 0;
00677 virtual
00678 bool
00679 is_open_sql() const = 0;
00681 virtual
00682 bool
00683 open_sql( bool async,
00684 const char* sql
00685 ) = 0;
00687 virtual
00688 bool
00689 exec_sql( bool async,
00690 const char* sql
00691 ) = 0;
00693 virtual
00694 bool
00695 open_proc( bool async,
00696 const char* name
00697 ) = 0;
00699 virtual
00700 bool
00701 exec_proc( bool async,
00702 const char* name
00703 ) = 0;
00708 virtual
00709 bool
00710 fetch_data( bool async,
00711 size_t start_row,
00712 size_t num_rows,
00713 bool forward
00714 ) = 0;
00716 virtual
00717 bool
00718 close_sql() = 0;
00720 virtual
00721 bool
00722 interrupt_request() = 0;
00731 virtual
00732 bool
00733 set_quote( char quote
00734 ) = 0;
00736 virtual
00737 void
00738 set_callback( async_db_notify* target
00739 ) = 0;
00741 virtual
00742 void
00743 remove_callback(async_db_notify* target
00744 ) = 0;
00745
00752 virtual
00753 bool
00754 param_bulk_store() = 0;
00756 virtual
00757 bool
00758 param_bulk_remove() = 0;
00760 virtual
00761 bool
00762 param_bulk_remove_all() = 0;
00763 };
00764
00765 #endif // _terimber_dbaccess_h_
00766