This is no longer supported, please consider using oranif instead.
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 the following libraries (for matching os and platfrom for the development system)
- instantclient-basic
- instantclient-sdk
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)
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/
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:
...
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
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"
We assume you have rebar3 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
The threadpool code (threadpool.cpp/h) is developed by Mathias Brossard mathias@brossard.org. 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.
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.
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.
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() |
The database user <<db_user>>
must have at least the following privileges:
-- Roles
GRANT CONNECT TO <<db_user>>;
GRANT RESOURCE TO <<db_user>>;
ALTER USER <<db_user>> DEFAULT ROLE ALL;
-- System Privileges
GRANT ALTER SESSION TO <<db_user>>;
GRANT ALTER SYSTEM TO <<db_user>>;
GRANT CREATE ANY DIRECTORY TO <<db_user>>;
GRANT CREATE DATABASE LINK TO <<db_user>>;
GRANT CREATE SEQUENCE TO <<db_user>>;
GRANT CREATE SESSION TO <<db_user>>;
GRANT CREATE SYNONYM TO <<db_user>>;
GRANT CREATE VIEW TO <<db_user>>;
GRANT DROP ANY DIRECTORY TO <<db_user>>;
-- Object Privileges
GRANT EXECUTE ON SYS.DBMS_STATS TO <<db_user>>;
GRANT SELECT ON SYS.GV_$PROCESS TO <<db_user>>;
GRANT SELECT ON SYS.GV_$SESSION TO <<db_user>>;
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:
rebar3 compile
rebar3 eunit
OciPort = erloci:new([{logging, false}, {env, []}]),
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),
SelStmt = OciSession:prep_sql("SELECT lastname, firstname from testtable where personid > :a "),
SelStmt:bind_vars([{<<":a">>,'SQLT_INT'}]),
SelStmt:exec_stmt([{1}]),
Returns:
{cols, [Definition]}
where
Definition is {ColumnName, ColumnType, ColumnSize, Precision, Scale}
SelStmt:fetch_rows(NumRows)
Returns:
{{rows, [Row]}, IsComplete}
- STL term class for wrapping erlang term
- Native process redesigned to OO
- Support Variable binding for Input
- Concurrent connection and statements
- Common test for load testing
- Compiled with rebar3
- CommonTests restructured
- Compile with Visual Studio 2017 Community Edition tool chain
- Testing and stabilization
- Wiki
- In/Out bind variables and arrays