Erlang and Sybase/Oracle on Linux

Martin J. Logan <>
Wed Nov 28 18:03:17 CET 2001


Rudolph van Graan wrote:

> Hi there,
>
> Does anyone know how difficult (if it all possible) to use the ODBC
> interface of erlang to access a Sybase or Oracle database on linux/x86?
> Any pointers on how to get this going quickly?
>
> Thanks in advance!
>
> Rudolph

We have gotten ODBC to interface with an oracle DB to work on slackware
linux with and Oracle ODBC Driver by easysoft(www.easysoft.org and
www.easysoft.com).  The process of getting it working is a bit tricky. I
am including the make file that I used as well as the .ini files that are
crucial to proper installation. These should ideally be placed in your
/etc directory and point to the .so files provided by the ODBC driver. I
hope this helps.

                    Cheers,
                    Martin
-------------- next part --------------
[ODBC Data Sources]
dBase=MERANT 3.70 dBase Driver
SybaseASE=MERANT 3.70 Sybase ASE Driver
Oracle8=MERANT 3.70 Oracle 8 Driver
Oracle7=Easysoft Oracle Driver
InformixWP=MERANT 3.70 Informix Clientless Driver
Text=MERANT 3.70 Text Driver
MS_SQLServer7=MERANT SQLServer driver
MySQL=MySQL driver
Merant=MERANT 3.70 Oracle 8 Driver
Easysoft=Easysoft 1.0.0.2 Driver

[dBase]
Driver=/u1/odbc/lib/ivdbf16.so
Description=dBase
Database=/u1/odbc/demo

[SybaseASE]
Driver=/u1/odbc/lib/ivase16.so
Description=SybaseASE
Database=odbc
LogonID=odbc01
Password=odbc01
NetworkAddress=server,port

[Oracle7]
Driver=/usr/local/easysoft/oracle/libesoracle.so
Description=Oracle7
Database=cantest
LogonID=vail
Password=dragon123

[Easysoft]
Driver=/usr/local/easysoft/oracle/libesoracle.so
Description=Easysoft
Database=cantest
LogonID=vail
Password=dragon123

[Oracle8]
Driver=/u1/odbc/lib/ivor816.so
Description=Merant
ServerName=CANTEST
LogonID=vail
Password=dragon123


[InformixWP]
Driver=/u1/odbc/lib/ivifcl16.so
Description=Informix Clientless Driver
Database=odbc
LogonID=odbc01
Password=odbc01
HostName=beluga
PortNumber=1526
ServerName=beluga914

[Text]
Driver=/u1/odbc/lib/ivtxt16.so
Description=Text driver
Database=/u1/odbc/demo

[MS_SQLServer7]
Driver=/u1/odbc/lib/ivmsss16.so
Description=SQL Server
Database=
Address=
LogonID=odbc01
Password=odbc01
QuotedId=No
AnsiNPW=No

[MySQL]
Driver=/u1/odbc/lib/ivmysql16.so
Description=MySQL driver
LogonID=login
Password=pass
Database=test
HostName=server

 
[ODBC]
Trace=0
TraceFile=odbctrace.out
TraceDll=/u1/odbc/lib/odbctrac.so
InstallDir=/u1/odbc
-------------- next part --------------
[ODBC Drivers]
Oracle7 = Installed
Merant = Installed
Easysoft= Installed

[ODBC Connection Pooling]
PerfMon    = 0
Retry Wait =

[Oracle7]
Driver   = /usr/local/easysoft/oracle/libesoracle.so
Setup    = /home/sam/.odbc.ini
DATABASE = cantest
PASSWORD = dragon123
TRACE    = ON
USER     = vail

[Easysoft]
Driver   = /usr/local/easysoft/oracle/libesoracle.so
Setup    = /home/martin/.odbc.ini
DATABASE = cantest
PASSWORD = dragon123
TRACE    = ON
USER     = vail

[Oracle8]
Driver   = /u1/odbc/lib/ivor816.so
Setup    = /home/sam/easysoft/usr/local/lib/.odbc.ini
DATABASE = CANTEST
PASSWORD = dragon123
TRACE    = OFF
USER     = vail
-------------- next part --------------
#
# Makefile for Unix
# Written for gcc
#

# Edit these to match your installation
#
# ODBCROOT - root directory of the ODBC installation
#
ODBCROOT = /u1/odbc
#ODBCROOT = /usr/local/easysoft/unixODBC

# You might need to change these
#
# ODBCLDFLAGS = -L<location of ODBC library>
# ODBCLIBS = -l<name of ODBC library>
# ODBCINCLUDE = -I<location of ODBC include files>
# OTPROOT - root directory of the Erlang/OTP installation
#
#ODBCLDFLAGS = -L$(ODBCROOT)/lib
ODBCLDFLAGS = -L$(ODBCROOT)/lib
ODBCLIBS = -lodbc -lodbcinst
ODBCINCLUDE = -I$(ODBCROOT)/include
OTPROOT = /usr/local/src/otp_src_R7B-3

# The rest should be OK.
#
EMULATOR = %EMU%

ICROOT = $(OTPROOT)/lib/ic
EIROOT = $(OTPROOT)/lib/erl_interface

ERLC = $(OTPROOT)/bin/erlc

BINDIR = ../priv/bin
OBJDIR = ../priv/obj
EBINDIR = ../ebin

LINUXINCLUDE = /usr/local/include -I/usr/include
INCLUDES = -I. -I$(ICROOT)/include -I$(EIROOT)/include $(ODBCINCLUDE) \
	-I$(EIROOT)/src -I $(LINUXINCLUDE)
CFLAGS = $(INCLUDES)

GEN_ERLSRC = oe_odbclli.erl odbclli.erl
ERLSRC = $(GEN_ERLSRC) odbc.erl odbc_app.erl odbc_sup.erl
GEN_HRLS = $(GEN_ERLSRC:%.erl=%.hrl)
GEN_ERLOBJS = $(GEN_ERLSRC:%.erl=$(EBINDIR)/%.$(EMULATOR))
ERLOBJS = $(ERLSRC:%.erl=$(EBINDIR)/%.$(EMULATOR))

GEN_OBJS = $(OBJDIR)/oe_odbclli__s.o $(OBJDIR)/odbclli__s.o \
	$(OBJDIR)/oe_code_SQLCHAR_G_SEQ.o $(OBJDIR)/oe_code_SQLUSMALLINT_SEQ.o \
	$(OBJDIR)/oe_code_STRING_SEQ.o
ODBC_OBJS = $(OBJDIR)/odbcserver.o $(OBJDIR)/odbclli_cb.o $(GEN_OBJS)
GEN_H_FILES = odbclli__s.h oe_odbclli__s.h
GEN_CSRC = $(GEN_OBJS:$(OBJDIR)/%.o=%.c)

#EILDFLAGS = -L$(ICROOT)/priv/lib -L$(EIROOT)/lib
ERLANGFLAGS = -L/usr/local/lib/erlang/lib/erl_interface-3.2.9/lib
LINUXFLAGS = -L/usr/local/lib -L/usr/lib 
EILDFLAGS = -L$(ICROOT)/priv/lib/i686-pc-linux-gnu -L$(EIROOT)/lib
EILIBS = -lic -lerl_interface -lei -lnsl 
EILIBS2 = -lic -lerl_interface -lei -lnsl 
EICFLAGS = -W  -pa ../ebin -I ../include

all: $(BINDIR)/convert_macros $(BINDIR)/odbcserver ../include/odbc.hrl $(ERLOBJS)

clean:
	rm -f $(BINDIR)/* $(OBJDIR)/* $(ERLOBJS) *~ $(GEN_ERLSRC) 
	rm -f $(GEN_H_FILES) $(GEN_CSRC) $(GEN_HRLS) ../include/odbc.hrl

$(BINDIR)/convert_macros: $(OBJDIR)/convert_macros.o
	$(CC) $(CFLAGS) -o $@ $(OBJDIR)/convert_macros.o

$(BINDIR)/odbcserver: $(ODBC_OBJS)
	$(CC) $(CFLAGS) -o $@ $(ODBC_OBJS) $(EILDFLAGS) $(ODBCLDFLAGS) \
		$(ODBCLIBS) $(ERLANGFLAGS) $(LINUXFLAGS) $(EILIBS)

$(OBJDIR)/convert_macros.o:
	$(CC) $(CFLAGS) -o $@ -c convert_macros.c

$(OBJDIR)/odbcserver.o: odbcserver.c $(GEN_H_FILES)
	$(CC) $(CFLAGS) -o $@ -c odbcserver.c

$(OBJDIR)/odbclli_cb.o: odbclli_cb.c
	$(CC) $(CFLAGS) -o $@ -c odbclli_cb.c

../include/odbc.hrl: $(BINDIR)/convert_macros
	$(BINDIR)/convert_macros $@

$(GEN_H_FILES) $(GEN_CSRC): odbclli.idl
	$(ERLC) $(EICFLAGS) +'{be,c_server}' odbclli.idl

$(GEN_ERLSRC) $(GEN_HRLS): odbclli.idl
	$(ERLC) $(EICFLAGS) +'{be,erl_genserv}' odbclli.idl

$(GEN_OBJS):	$(GEN_CSRC)
	$(CC) $(CFLAGS) -o $@ -c $(@:$(OBJDIR)/%.o=%.c)

$(ERLOBJS): $(ERLSRC)
	$(ERLC) $(EFLAGS) -o $(EBINDIR) $(@:$(EBINDIR)/%.$(EMULATOR)=%.erl)


More information about the erlang-questions mailing list