Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k2informaticsgmbh/erloci
Erlang Oracle native driver - DEPRECATED, see https://github.com/K2InformaticsGmbH/oranif instead
https://github.com/k2informaticsgmbh/erloci
archived-repository c-plus-plus database deprecated deprecated-repo erlang erlang-driver instantclient obselete oci oracle thread-pool
Last synced: about 1 month ago
JSON representation
Erlang Oracle native driver - DEPRECATED, see https://github.com/K2InformaticsGmbH/oranif instead
- Host: GitHub
- URL: https://github.com/k2informaticsgmbh/erloci
- Owner: K2InformaticsGmbH
- License: apache-2.0
- Created: 2013-05-21T11:02:04.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-07-25T15:43:44.000Z (over 5 years ago)
- Last Synced: 2024-04-15T00:11:33.521Z (9 months ago)
- Topics: archived-repository, c-plus-plus, database, deprecated, deprecated-repo, erlang, erlang-driver, instantclient, obselete, oci, oracle, thread-pool
- Language: C++
- Homepage:
- Size: 8.36 MB
- Stars: 37
- Watchers: 12
- Forks: 12
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DEPRECATED
This is no longer supported, please consider using [oranif](https://github.com/K2InformaticsGmbH/oranif) instead.# erloci - An Erlang driver for the Oracle Call Interface
[![Build Status](https://travis-ci.org/K2InformaticsGmbH/erloci.svg?branch=master)](https://travis-ci.org/K2InformaticsGmbH/erloci) [![Coverage Status](https://coveralls.io/repos/github/K2InformaticsGmbH/erloci/badge.svg?branch=master)](https://coveralls.io/github/K2InformaticsGmbH/erloci?branch=master)
### Setup the development system
Create a environment variable OTPROOT pointing to erlang installation directory,
e.g. - in linux (if installed from RPM) its usually /usr/lib/erlang.
Download from [Oracle](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html) the following libraries (for matching os and platfrom for the development system)
1. instantclient-basic
2. instantclient-sdk### Windows
Unzip both into a directory and create the following enviroment variable
E.g. - if your instant client library version is 12.1 and you have unzipped 'instantclient-basic-windows*.zip' to C:\Oracle\instantclient\instantclient_12_1 then the sdk should be at C:\Oracle\instantclient\instantclient_12_1\sdk\
The include headers will be at C:\Oracle\instantclient\instantclient_12_1\sdk\include and static libraries at C:\Oracle\instantclient\instantclient_12_1\sdk\lib\msvc (note the path for VS project configuration later)### Linux / Mac OS X
Required system libraries
```
libevent
libevent-devel
```
Use rpms (recomended) to install basic and sdk. The default install path is usually (for x86_64 architecture)
For Mac you may use Homebrew (http://brew.sh) as package manager to install it.
```
OCI Headers : /usr/include/oracle/12.1/client64/
OCI Libraries : /usr/lib/oracle/12.1/client64/lib/
```### Create Environment variables
```
INSTANT_CLIENT_LIB_PATH = path to oci libraries
INSTANT_CLIENT_INCLUDE_PATH = path to oci headers
ERL_INTERFACE_DIR = path to erl_interface or erlang installation
```
Example `.bashrc` snippet:
```sh
...
INSTANT_CLIENT_LIB_PATH=$(find /usr/lib/oracle/ -type d -name client64)/lib
INSTANT_CLIENT_INCLUDE_PATH=$(find /usr/include/oracle/ -type d -name client64)
ERL_INTERFACE_DIR=$(find /usr/lib/erlang/lib/ -type d -name erl_interface-*)export INSTANT_CLIENT_LIB_PATH
export INSTANT_CLIENT_INCLUDE_PATH
export ERL_INTERFACE_DIR
...
```For example:
```
(x64 Fedora)
INSTANT_CLIENT_LIB_PATH = /usr/lib/oracle/12.1/client64/lib/
INSTANT_CLIENT_INCLUDE_PATH = /usr/include/oracle/12.1/client64/
ERL_INTERFACE_DIR = /usr/lib64/erlang/lib/erl_interface-3.7.15(x64 Windows 7)
INSTANT_CLIENT_LIB_PATH = C:\Oracle\instantclient\instantclient_12_1\
ERL_INTERFACE_DIR = C:\Program Files\erlang\erl5.10.4\lib\erl_interface-3.7.15
```### Ubuntu (14.04.2 LTS 'trusty')
```
sudo apt-get install libevent-dev
sudo apt-get install alien dpkg-dev debhelper build-essential
sudo alien oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
sudo alien oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
sudo dpkg -i oracle-instantclient12.1-basic_12.1.0.2.0-2_amd64.deb
sudo dpkg -i oracle-instantclient12.1-devel_12.1.0.2.0-2_amd64.deb~/.profile
export INSTANT_CLIENT_LIB_PATH="/usr/lib/oracle/12.1/client64/lib/"
export INSTANT_CLIENT_INCLUDE_PATH="/usr/include/oracle/12.1/client64/"
export ERL_INTERFACE_DIR="/usr/lib/erlang/lib/erl_interface-3.8.2"
```### Compiling
We assume you have [rebar3](https://www.rebar3.org/) somewhere on your path. Rebar3 will take care of the Erlang and C++ sources.rebar3 compile
Please check the rebar3 documentation for how to add erloci as a dependency to your project.**DEPRICATION WARNING** Visual Studio 2008 and Visual Studio 2013 are no longer supported please build with Visual Studio 2017 (Community Edition) instead
Issue `rebar3 compile` as usual; then don't forget to revert temporarily changed vcxproj files: `git reset --hard`.
__NOTE__: Setting the environment variables for the comand line tools might be needed: ``"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64``
### 3rd party dependencies
#### Threadpool
The threadpool code (threadpool.cpp/h) is developed by Mathias Brossard [email protected]. His threadpool library is hosted at https://github.com/mbrossard/threadpool.
This library is unused (not linked) in a Windows environment. For an easier installation process we include the required threadpool files in the erloci repo. So this is NOT a dependency you have to resolve by yourself.#### Oracle Call Interface (OCI)
OCI provides a high performance, native 'C' language based interface to the Oracle Database. There is no ODBC layer between your application and the database. Since we don't want to distribute the Oracle Code you MUST download the OCI Packages (basic and devel) from the Oracle Website: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html.#### Compile ERLOCI in Windows command line
Make sure you have `MSbuild.exe` in path. After that `rebar3 compile` will take care the rest. Currently erloci can only be build with VS2008.### Erlang to/from Oracle datatype mapping (currently)
oracle|erlang
---|---
SQLT_INT|integer()
SQLT_CHR,SQLT_AFC|binary()
SQLT_FLT|float()
SQLT_IBDOUBLE|float()
SQLT_BIN|binary()
SQLT_DAT|binary()
SQLT_TIMESTAMP|binary()
SQLT_TIMESTAMP_LTZ|binary()
SQLT_INTERVAL_YM|binary()
SQLT_INTERVAL_DS|binary()
SQLT_IBFLOAT|float()### Eunit test
The database user `<>` must have at least the following privileges:-- Roles
GRANT CONNECT TO <>;
GRANT RESOURCE TO <>;
ALTER USER <> DEFAULT ROLE ALL;
-- System Privileges
GRANT ALTER SESSION TO <>;
GRANT ALTER SYSTEM TO <>;
GRANT CREATE ANY DIRECTORY TO <>;
GRANT CREATE DATABASE LINK TO <>;
GRANT CREATE SEQUENCE TO <>;
GRANT CREATE SESSION TO <>;
GRANT CREATE SYNONYM TO <>;
GRANT CREATE VIEW TO <>;
GRANT DROP ANY DIRECTORY TO <>;
-- Object Privileges
GRANT EXECUTE ON SYS.DBMS_STATS TO <>;
GRANT SELECT ON SYS.GV_$PROCESS TO <>;
GRANT SELECT ON SYS.GV_$SESSION TO <>;The Oracle connection information are taken from the file `connect.config` in directory `test`. Please change it to point to your database before executing the steps below:
1.
rebar3 compile
2.rebar3 eunit
## API Description through examples
### Create a new erloci environment
```
OciPort = erloci:new([{logging, false}, {env, []}]),
```
### Get an OCI Session
```
Tns = <<"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=XE)))">>,
Pswd= <<"XXXXXX">>,
User= <<"User">>,
OciSession = OciPort:get_session(Tns, User, Pswd),
```
### Prepare an OCI Statement
```
SelStmt = OciSession:prep_sql("SELECT lastname, firstname from testtable where personid > :a "),
```
### Bind Variable types
```
SelStmt:bind_vars([{<<":a">>,'SQLT_INT'}]),
```
### Execute the statement with bind values
```
SelStmt:exec_stmt([{1}]),
```Returns:
`{cols, [Definition]}` where
Definition is `{ColumnName, ColumnType, ColumnSize, Precision, Scale}`### Fetch result rows
```
SelStmt:fetch_rows(NumRows)
```
Returns:
`{{rows, [Row]}, IsComplete}`### CHANGE LOG
#### 0.0.2
1. STL term class for wrapping erlang term
1. Native process redesigned to OO
1. Support Variable binding for Input
1. Concurrent connection and statements
1. Common test for load testing
#### 0.1.0
1. Compiled with rebar3
1. CommonTests restructured
#### 0.1.1
1. Compile with Visual Studio 2017 Community Edition tool chain### Work-In-Progess
1. Testing and stabilization
2. Wiki### TODOs
1. In/Out bind variables and arrays