Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Accessing Database from multiple files
Accessing Database from multiple files [message #21726] Tue, 02 June 2009 15:23 Go to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
I am having a bit of problems coming up with either all my field names being either already defined:

main.obj : error LNK2005: "void __cdecl 
TABLE_SUPPLIER(class Upp::SqlSchema &)" 
(?TABLE_SUPPLIER@@YAXAAVSqlSchema@Upp@@@Z) already defined 
in base_data.obj


Or not defined:

C:\Develop\Projects\UppApps\BeekPRO\base_data.cpp(8) :
error C2065: 'HIVE_TYPE' : undeclared identifier


What I have is BeekPRO.h (only revelant portions):

#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <BeekPRO/BeekPRO.sch>

#include <Sql/sch_schema.h>
#include <Sql/sch_header.h>
#include <Sql/sch_source.h>


I've tried moving the sch_source.h include from BeekPRO.h to BeekPRO.cpp thinking that the sch_header.h was just the definitions but sch_source.h was the actual source but that is not making a difference.

What I want is to be able to access the schema data from many .cpp files, thus, I can take an application that is getting more complex every minute and break it into smaller manageable files:

* BeekPRO.cpp - main file
* Apiary.cpp - Add/Edit/Remove apiaries
* Hive.cpp - Add/Edit/Remove hives
* Supplier.cpp - Add/Edit/Remove suppliers
* ... etc ...

Jeremy
Re: Accessing Database from multiple files [message #21727 is a reply to message #21726] Tue, 02 June 2009 15:47 Go to previous messageGo to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
Oh, never mind. I got it:

// BeekPRO.h
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <BeekPRO/BeekPRO.sch>

#include <Sql/sch_header.h>

// BeekPRO.cpp
#include <Sql/sch_schema.h>
#include <Sql/sch_source.h>


This allows me to include BeekPRO.h from any other .cpp file and have access to the field definitions.

Jeremy
Re: Accessing Database from multiple files [message #45110 is a reply to message #21727] Wed, 02 September 2015 17:03 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hi everyone,

I have this redefinition problem. Trying to do like this:

--- main.cpp ---
#include <Core/Core.h>
using namespace Upp;

#include "classBOOK.h"
#include "classBORROW.h"

CONSOLE_APP_MAIN
{
}

--- sqlheader.h -- 
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <testsql/schema1.sch>
#include "Sql/sch_header.h"


--- classBOOK.h ----
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
using namespace Upp;

#include "sqlheader.h"

class CBook
{
	CBook();
};

--- classBOOK.cpp ----

#include "classBOOK.h"
#include "Sql/sch_source.h"
#include "Sql/sch_schema.h"

CBook::CBook(){}

--- classBORROW.h ---
#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>
using namespace Upp;

#include "sqlheader.h"

class CBorrow
{
	CBorrow();
};

--- classBORROW.cpp ---
#include "classBORROW.h"
#include "Sql/sch_source.h"
#include "Sql/sch_schema.h"

CBorrow::CBorrow(){}


I get this error
Quote:

In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBORROW.h:8,
from D:\MyApps\testsql\testsql.cpp:5:
D:\MyApps/testsql/schema1.sch:1:1: error: redefinition of 'struct S_BOOK'
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBOOK.h:8,
from D:\MyApps\testsql\testsql.cpp:4:
D:\MyApps/testsql/schema1.sch:1:1: error: previous definition of 'struct S_BOOK'
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBORROW.h:8,
from D:\MyApps\testsql\testsql.cpp:5:
D:\MyApps/testsql/schema1.sch:7:1: error: redefinition of 'struct S_BORROW_RECORD'
In file included from D:\upp\uppsrc/Sql/sch_model.h:162:0,
from D:\upp\uppsrc/plugin/sqlite3/Sqlite3Schema.h:95,
from D:\upp\uppsrc/Sql/sch_header.h:38,
from D:\MyApps\testsql\sqlheader.h:3,
from D:\MyApps\testsql\classBOOK.h:8,
from D:\MyApps\testsql\testsql.cpp:4:
D:\MyApps/testsql/schema1.sch:7:1: error: previous definition of 'struct S_BORROW_RECORD'
testsql: 3 file(s) built in (0:03.65), 1217 msecs / file, duration = 3719 msecs, parallelization 73%

There were errors. (0:03.75)


Do someone can help me please to avoid redefinition.
Thanks in advanced
Re: Accessing Database from multiple files [message #45116 is a reply to message #45110] Fri, 04 September 2015 17:23 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi ratah,

I think your problem is that you include Sql/sch_schema.h as well. Look at it's source, you'll see that it only includes sch_header.h and sch_source.h. You should use either only sch_schema.h (usually useful only when all your sql related code is in single cpp file) or sch_header.h in your header files and sch_source.h in exactly one of your cpp files.

Best regards,
Honza
Previous Topic: PATCH/BUGFIX Oracle asTable Failure - Solution
Next Topic: Application crashes when connected to MySQL, what am I doing wrong?
Goto Forum:
  


Current Time: Fri Mar 29 00:34:25 CET 2024

Total time taken to generate the page: 0.01134 seconds