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 » Can I create DBF files?
Can I create DBF files? [message #4526] Mon, 14 August 2006 13:03 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I've no experience with database and how U++ works with them. Only one time in the past I needed to create three files in the old DB III or DB IV format. For this purpose I used the Xbase library. Now I wonder if in U++ I can export directly in such format.

Luigi
Re: Can I create DBF files? [message #4534 is a reply to message #4526] Mon, 14 August 2006 18:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
There is some support in TCore/dbf.h

Mirek
Re: Can I create DBF files? [message #5009 is a reply to message #4534] Wed, 30 August 2006 18:33 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Mon, 14 August 2006 18:08

There is some support in TCore/dbf.h

Mirek


I found it but I'm unable to use the class. Is there around an example that show how to create and save a DB in dbf format?
I need only to export in dbf a table (console mode is enough)

Many thanks in advance,
Luigi
Re: Can I create DBF files? [message #5038 is a reply to message #5009] Thu, 31 August 2006 20:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Best I can do now is to post some snippets from my apps using BbfStreams. Be aware, it is combined with Oracle SQL... (usually, these are some imports/exports DBF<->Oracle).

	DbfStream dbf;
	if(!dbf.Open(String(~importcm.file), false)) {
		Exclamation("Nelze otevřít vstupní soubor !");
		return;
	}
	Progress pi;
	pi.SetText("Parcela %d");
	while(dbf.Fetch()) {
		if(pi.StepCanceled()) break;
		int q = SQL % Select(PARCELA_SEQ).From(PARCELA)
		              .Where(KU == ~importcm.ku &&
		                     SKUPINA == dbf["PARSKUP"] &&
		                     CISLO == dbf["PARCIS"] &&
		                     LOM == dbf["PARPOD"] &&
		                     PODLOM == dbf["PARDIL"]);
		if(!IsNull(q)) {
			SQL * Delete(EN_CENOMAPA).Where(PARCELA_SEQ == q && DTM_OD == ~importcm.datum);
			SQL * Insert(EN_CENOMAPA)
					(EN_CENOMAPA_SEQ, ++SeqEN)
					(PARCELA_SEQ, q)
					(DTM_OD, ~importcm.datum)
					(CENA, dbf["CENA2001"]);
		}
	}


void ExportCRO(const Array<OsobaRef>& list)
{
	AddressCache cache;
	if(!cache.Load())
	{
		PromptOK("Načítání adres bylo přeru¨eno u¸ivatelem.");
		return;
	}
	String fn = "lidi.dbf";
	ReadConfigItem(fn, config);
	if(!FileDlg(FDLG_SAVE, fn, "dbf", "DBF soubory (*.dbf)|*.dbf||"))
		return;
	
	static const struct FldDesc
	{
		const char *name;
		byte        width;
	}
	field_map[] =
	{
		{ "PRIJMENI",  0x1B },
		{ "JMENO",     0x0F },
		{ "RPRIJMENI", 0x1B },
		{ "RC",        0x0A },
		{ "TP_OBEC",   0x14 },
		{ "TP_COBCE",  0x0C },
		{ "TP_ULICE",  0x14 },
		{ "TP_CP",     0x05 },
	};

	Array<DbfStream::Field> fields;
	int i;
	for(i = 0; i < __countof(field_map); i++)
		fields << DbfStream::Field::Text(field_map[i].name, field_map[i].width);
	DbfStream output;
	if(!output.Create(fn, fields, CHARSET_MJK))
	{
		PromptOK("Nelze vytvořit soubor [* \1" + fn + "\1].");
		return;
	}
	WriteConfigItem(fn, config);

	ProgressMeter progress("Exportuji osobu %d...", 1000, list.GetCount(), 0);
	for(i = 0; i < list.GetCount(); i++)
	{
		const OsobaRef& ref = list[i];
		Adresa a = cache[ref.TRV_BYDL];
		Vector<Value> values;
		values.Add(ref.GetPrijm());
		values.Add(ref.GetJmeno());
		values.Add(ref.GetRodPrijm());
		values.Add(ref.GetRcIco());
		values.Add(a.obec);
		values.Add(a.ctvrt);
		values.Add(a.ulice);
		values.Add(a.cpop);
		output.WriteRow(values);
		if(progress.StepCancelled())
		{
			PromptOK("Export byl přeru¨en u¸ivatelem.\n"
				"Soubor [* \1" + fn + "\1] obsahuje neúplná data.");
			break;
		}
	}

	if(!output.Close())
		PromptOK("Chyba při zápisu do souboru [* \1" + fn + "\1].");
}

Re: Can I create DBF files? [message #5040 is a reply to message #5038] Thu, 31 August 2006 21:00 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Thu, 31 August 2006 20:49

Best I can do now is to post some snippets from my apps using BbfStreams. Be aware, it is combined with Oracle SQL... (usually, these are some imports/exports DBF<->Oracle).



Thank you very much. I will study it carefully.
Luigi
Previous Topic: build CppSQLite failed
Next Topic: OkCommit problem
Goto Forum:
  


Current Time: Sun Apr 28 20:58:52 CEST 2024

Total time taken to generate the page: 3.00598 seconds