Warning, /sdk/codevis/thirdparty/soci/docs/backends/firebird.md is written in an unsupported language. File is not indexed.
0001 # Firebird Backend Reference 0002 0003 SOCI backend for accessing Firebird database. 0004 0005 ## Prerequisites 0006 0007 ### Supported Versions 0008 0009 The SOCI Firebird backend supports versions of Firebird from 1.5 to 2.5 and can be used with 0010 either the client-server or embedded Firebird libraries. 0011 The former is the default, to select the latter set `SOCI_FIREBIRD_EMBEDDED` CMake option to `ON` 0012 value when building. 0013 0014 ### Tested Platforms 0015 0016 |Firebird |OS|Compiler| 0017 |--- |--- |--- | 0018 |1.5.2.4731|SunOS 5.10|g++ 3.4.3| 0019 |1.5.2.4731|Windows XP|Visual C++ 8.0| 0020 |1.5.3.4870|Windows XP|Visual C++ 8.0 Professional| 0021 |2.5.2.26540|Debian GNU/Linux 7|g++ 4.7.2| 0022 |2.5.8.27089|macOS High Sierra 10.13.5|AppleClang 9.1.0.9020039| 0023 0024 ### Required Client Libraries 0025 0026 The Firebird backend requires Firebird's `libfbclient` client library. 0027 For example, on Ubuntu Linux, for example, `firebird-dev` package and its dependencies are required. 0028 0029 ## Connecting to the Database 0030 0031 To establish a connection to a Firebird database, create a Session object using the firebird 0032 backend factory together with a connection string: 0033 0034 ```cpp 0035 BackEndFactory const &backEnd = firebird; 0036 session sql(backEnd, "service=/usr/local/firbird/db/test.fdb user=SYSDBA password=masterkey"); 0037 ``` 0038 0039 or simply: 0040 0041 ```cpp 0042 session sql(firebird, "service=/usr/local/firbird/db/test.fdb user=SYSDBA password=masterkey"); 0043 ``` 0044 0045 The set of parameters used in the connection string for Firebird is: 0046 0047 * service 0048 * user 0049 * password 0050 * role 0051 * charset 0052 0053 The following parameters have to be provided as part of the connection string : *service*, *user*, 0054 *password*. Role and charset parameters are optional. 0055 0056 Once you have created a `session` object as shown above, you can use it to access the database, for example: 0057 0058 ```cpp 0059 int count; 0060 sql << "select count(*) from user_tables", into(count); 0061 ``` 0062 0063 (See the [connection](../connections.md) and [data binding](../binding.md) documentation 0064 for general information on using the `session` class.) 0065 0066 ## SOCI Feature Support 0067 0068 ### Dynamic Binding 0069 0070 The Firebird backend supports the use of the SOCI `row` class, which facilitates retrieval of data whose 0071 type is not known at compile time. 0072 0073 When calling `row::get<T>()`, the type you should pass as T depends upon the underlying database type. 0074 For the Firebird backend, this type mapping is: 0075 0076 |Firebird Data Type|SOCI Data Type|`row::get<T>` specializations| 0077 |--- |--- |--- | 0078 |numeric, decimal (where scale > 0)|dt_double|double| 0079 |numeric, decimal [^1] (where scale = 0)|dt_integer, dt_double|int, double| 0080 |double precision, float|dt_double|double| 0081 |smallint, integer|dt_integer|int| 0082 |char, varchar|dt_string|std::string| 0083 |date, time, timestamp|dt_date|std::tm| 0084 0085 [^1] There is also 64bit integer type for larger values which is 0086 currently not supported. 0087 0088 (See the [dynamic resultset binding](../types.md#dynamic-binding) documentation for general information 0089 on using the `Row` class.) 0090 0091 ### Binding by Name 0092 0093 In addition to [binding by position](../binding.md#binding-by-position), the Firebird backend supports 0094 [binding by name](../binding.md#binding-by-name), via an overload of the `use()` function: 0095 0096 ```cpp 0097 int id = 7; 0098 sql << "select name from person where id = :id", use(id, "id") 0099 ``` 0100 0101 It should be noted that parameter binding by name is supported only by means of emulation, 0102 since the underlying API used by the backend doesn't provide this feature. 0103 0104 ### Bulk Operations 0105 0106 The Firebird backend has full support for SOCI [bulk operations](../binding.md#bulk-operations) interface. 0107 This feature is also supported by emulation. 0108 0109 ### Transactions 0110 0111 [Transactions](../transactions.md) are also fully supported by the Firebird backend. 0112 In fact, an implicit transaction is always started when using this backend if one hadn't been 0113 started by explicitly calling `begin()` before. The current transaction is automatically 0114 committed in `session` destructor. 0115 0116 ### BLOB Data Type 0117 0118 The Firebird backend supports working with data stored in columns of type Blob, 0119 via SOCI [BLOB](../lobs.md) class. 0120 0121 It should by noted, that entire Blob data is fetched from database to allow random read and write access. 0122 This is because Firebird itself allows only writing to a new Blob or reading from existing one - 0123 modifications of existing Blob means creating a new one. 0124 Firebird backend hides those details from user. 0125 0126 ### RowID Data Type 0127 0128 This feature is not supported by Firebird backend. 0129 0130 ### Nested Statements 0131 0132 This feature is not supported by Firebird backend. 0133 0134 ### Stored Procedures 0135 0136 Firebird stored procedures can be executed by using SOCI [Procedure](../procedures.md) class. 0137 0138 ## Native API Access 0139 0140 SOCI provides access to underlying datbabase APIs via several `get_backend()` functions, 0141 as described in the [Beyond SOCI](../beyond.md) documentation. 0142 0143 The Firebird backend provides the following concrete classes for navite API access: 0144 0145 |Accessor Function|Concrete Class| 0146 |--- |--- | 0147 |session_backend * session::get_backend()|firebird_session_backend| 0148 |statement_backend * statement::get_backend()|firebird_statement_backend| 0149 |blob_backend * blob::get_backend()|firebird_blob_backend| 0150 |rowid_backend * rowid::get_backend()| 0151 0152 ## Backend-specific extensions 0153 0154 ### firebird_soci_error 0155 0156 The Firebird backend can throw instances of class `firebird_soci_error`, which is publicly derived 0157 from `soci_error` and has an additional public `status_` member containing the Firebird status vector.