Connecting Genero to SQL Server
Genero provides a database driver for use with Easysoft's SQL Server ODBC driver, and this enables you to create Genero programs that use SQL Server as their backend.
- Download the SQL Server ODBC driver for 64-bit Linux. (Registration required.)
- Install and license the SQL Server ODBC driver on the machine where Genero is or will be installed.
For installation instructions, see the ODBC driver documentation.
Note You need the unixODBC Driver Manager installed on your machine. The Easysoft distribution includes a version of the unixODBC Driver Manager that the Easysoft SQL Server ODBC driver has been tested with. The Easysoft driver setup program gives you the option to install unixODBC.
- Create an ODBC data source in /etc/odbc.ini that connects to the SQL Server database you want to access from Genero. For example:
[MSSQL-GENERO] Driver = Easysoft ODBC-SQL Server Server = my_machine\SQLEXPRESS User = my_domain\my_user Password = my_password # If the database you want to connect to is the default # for the SQL Server login, omit this attribute Database = Northwind
- Use isql to test the new data source. For example:
cd /usr/local/easysoft/unixODBC/bin ./isql.sh -v MSSQL-GENERO
At the prompt, type "help" to display a list of tables. To exit, press return in an empty prompt line.
If you are unable to connect, refer to this article and the SQL Server ODBC Driver Knowledge Base for assistance.
- If you have not already done so, install Genero on this machine.
Note One of our customers has reported to us that if you want to use Genero with SQL Server 2016, you need to use Genero 3.00.10 or later.During setup, you are prompted to choose the default database for fglrun. If you want SQL Server 2014 or earlier as your default database, choose option
when prompted. If you want to use SQL Server 2016 or later, choose
. If you do not want to use SQL Server as the default database, choose another database. You can set the database on a per application basis by specifying the database driver to use in your Genero source code.
- Create a Genero program that retrieves some SQL Server data:
$ more connect.4gl MAIN DEFINE varchar_col VARCHAR(100) # You can omit +driver... if you dbmesm_1 is the default driver in FGLPROFILE. CONNECT TO "MSSQL-GENERO+driver='dbmesm_1'" DECLARE xx CURSOR FOR SELECT * FROM MyVarcharTable FOREACH xx INTO varchar_col DISPLAY varchar_col CLIPPED END FOREACH END MAIN
- Set the environment so that Genero can load the SQL Server ODBC driver:
If didn't install the Easysoft driver under /usr/local, amend the path accordingly.
- Compile and run your program:
$ cd /opt/fourjs/gep/fgl/bin/ $ ./fglcomp connect.4gl $ ./fglrun connect.42m Value1 Value2
- If you have any problems running the program, try setting FGLSQLDEBUG:
$ export FGLSQLDEBUG=3 $ ./fglrun connect.42m SQL: CONNECT | 4gl source : connect.4gl line=3 | loading driver : [/opt/fourjs/gep/fgl/dbdrivers/dbmesm_1] | Dynamic linker error: [libessqlsrv.so: cannot open shared object file: No such file or directory]... | loading driver : [/opt/fourjs/gep/fgl/dbdrivers/dbmesm_1] | Dynamic linker error: [libessqlsrv.so: cannot open shared object file: No such file or directory]... Program stopped at 'connect.4gl', line number 3. SQL statement error number -6366 (0). Could not load database driver dbmesm_1. Set FGLSQLDEBUG to get more details. $ export LD_LIBRARY_PATH=/usr/local/easysoft/sqlserver/lib $ unset FGLSQLDEBUG $ ./fglrun connect.42m Value1 Value2