Subject Compiling Multiple Embedded SQL (*.e) files
Author rbozzz
Hi,

Anyone who can help me with my problems in Embedded SQL using
Linux C.. Im having trouble dealing with multiple *.e files in my
project with different database connections. When Im trying to
compile my project using gcc compiler the compiler complains about
multiple definitions of gds_database and gds_trans. Below are the
codes, what or where do i made an error?

************* Embedded SQL file #1 **************

#include <stdlib.h> // getenv()
#include <string.h> // memset()

#include <stddefs.h>
#include <frontier.h>
#include <message.h>
#include <atm.h>
#include <utils.h>
#include <stderrcd.h>
#include <console.h>
#include <requests_queue.h>
#include <osfa.h>


Msgheadersettings msghdrsettings;
Message rspmsg;
char rsp[MAX_STRING + 1];

EXEC SQL INCLUDE SQLCA;

/* * * * * * * CIF_HOST * * * * * * * * */
int sql_opendbCIF(char* pSZenv1, char* pSZdbname1)
{
EXEC SQL
BEGIN DECLARE SECTION;
char dbname[LONG_STRING + 1];
EXEC SQL
END DECLARE SECTION;

char* envptr;

envptr = (char*) getenv(pSZenv1);

if (envptr != (char* )NULL)
sprintf(dbname, "%s/database_files/%s", envptr,
pSZdbname1);
else
sprintf(dbname, "%s/database_files/%s", pSZenv1,
pSZdbname1);

EXEC SQL
SET DATABASE ACSDB
= '/home/asecsoft/rbo/frontier/database_files/CIFHOST.GDB';


if ((sql_error("sql_opendbCIF()", "Opening database
as ACSDB\n")) == NOGOOD)
return (NOGOOD);

EXEC SQL
CONNECT :dbname AS ACSDB USER 'sysdba'
PASSWORD 'masterkey';

if ((sql_error("sql_opendbCIF()", "Connect error to
database")) == NOGOOD)
return (NOGOOD);

EXEC SQL
SET TRANSACTION READ WRITE ISOLATION LEVEL
READ COMMITTED USING ACSDB;

if ((sql_error("sql_opendbCIF()", "SET TRANSACTION
error")) == NOGOOD)
return (NOGOOD);

#ifdef DEBUG
logger(logfile, TRACELOG, "sql_opendbCIF():
Successful...\n");
#endif

return (GOOD);
}

int sql_commitCIF(int pcommit_type)
{
int Dstatus;

switch(pcommit_type)
{
case COMMIT_RETAIN:

EXEC SQL
COMMIT RETAIN ACSDB;

break;

case COMMIT_WORK:
EXEC SQL
COMMIT ACSDB;
sql_closedbCIF();
break;
case ROLLBACK_WORK:
EXEC SQL
ROLLBACK ACSDB;
break;
default:
logger(logfile, TRACELOG, "sql_commitCIF():
Invalid commit type [%d]\n", pcommit_type);
return (NOGOOD);
}

Dstatus = sql_error("sql_commitCIF()", "commit error");
#ifdef DEBUG
if (Dstatus == GOOD)
logger(logfile, TRACELOG, "sql_commitCIF():
commit transaction successful\n");
#endif
return (Dstatus);
}

int sql_closedbCIF(void)
{

EXEC SQL
DISCONNECT ACSDB;

if((sql_error("sql_closedbCIF()", "CLOSE ACSDB error")) ==
NOGOOD)
return (NOGOOD);

return (GOOD);
}

int sql_error(char* pmodule, char* pmsg)
{

if (SQLCODE)
{
logger(logfile, TRACELOG, "%s: %s: %d, ", pmodule,
pmsg, SQLCODE);
isc_print_status(gds__status);
logger(logfile, TRACELOG, "\n");
return (NOGOOD);
}
return (GOOD);
}


***************** END OF FILE #1 *****************

this is the second file
***************** EMBEDDED SQL FILE #2 ***************

#include <stdlib.h> // getenv()
#include <string.h> // memset()

#include <stddefs.h>
#include <frontier.h>
#include <message.h>
#include <atm.h>
#include <utils.h>
#include <stderrcd.h>
#include <console.h>
#include <requests_queue.h>
#include <osfa.h>

Msgheadersettings msghdrsettings;
Message rspmsg;
char rsp[MAX_STRING + 1];


int sql_opendbDMM(char* pSZenv1, char* pSZdbname1)
{
EXEC SQL
BEGIN DECLARE SECTION;
char dbname[LONG_STRING + 1];
EXEC SQL
END DECLARE SECTION;

char* envptr;

envptr = (char*) getenv(pSZenv1);

if (envptr != (char* )NULL)
sprintf(dbname, "%s/database_files/%s", envptr,
pSZdbname1);
else
sprintf(dbname, "%s/database_files/%s", pSZenv1,
pSZdbname1);

EXEC SQL
SET DATABASE ACSDMMDB
= '/home/asecsoft/rbo/frontier/database_files/DMMHOST.GDB';


if ((sql_error("sql_opendbDMM()", "Opening database
as ACSDMMDB\n")) == NOGOOD)
return (NOGOOD);

EXEC SQL
CONNECT :dbname AS ACSDMMDB USER 'sysdba'
PASSWORD 'masterkey';

if ((sql_error("sql_opendbDMM()", "Connect error to
database")) == NOGOOD)
return (NOGOOD);

EXEC SQL
SET TRANSACTION READ WRITE ISOLATION LEVEL
READ COMMITTED USING ACSDMMDB;

if ((sql_error("sql_opendbDMM()", "SET TRANSACTION
error")) == NOGOOD)
return (NOGOOD);

#ifdef DEBUG
logger(logfile, TRACELOG, "sql_opendbDMM():
Successful...\n");
#endif

return (GOOD);
}

int sql_commitDMM(int pcommit_type)
{
int Dstatus;

switch(pcommit_type)
{
case COMMIT_RETAIN:

EXEC SQL
COMMIT RETAIN ACSDMMDB;

break;

case COMMIT_WORK:
EXEC SQL
COMMIT ACSDMMDB;
sql_closedbCIF();
break;
case ROLLBACK_WORK:
EXEC SQL
ROLLBACK ACSDMMDB;
break;
default:
logger(logfile, TRACELOG, "sql_commitDMM():
Invalid commit type [%d]\n", pcommit_type);
return (NOGOOD);
}

Dstatus = sql_error("sql_commitDMM()", "commit error");
#ifdef DEBUG
if (Dstatus == GOOD)
logger(logfile, TRACELOG, "sql_commitDMM():
commit transaction successful\n");
#endif
return (Dstatus);
}

int sql_closedbDMM(void)
{

EXEC SQL
DISCONNECT ACSDMMDB;

if((sql_error("sql_closedbDMM()", "CLOSE ACSDMMDB error"))
== NOGOOD)
return (NOGOOD);

return (GOOD);
}

int sql_errorDMM(char* pmodule, char* pmsg)
{

if (SQLCODE)
{
logger(logfile, TRACELOG, "%s: %s: %d, ", pmodule,
pmsg, SQLCODE);
isc_print_status(gds__status);
logger(logfile, TRACELOG, "\n");
return (NOGOOD);
}
return (GOOD);
}

......
......

***************** END OF FILE #2 ********************

Thanks in advance.