Normal Topic Trying to dump database into text file (Read 895 times)
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Trying to dump database into text file
Dec 1st, 2006 at 7:15pm
Print Post Print Post  
Hey all,

I'm in my last phase of upgrading our sales database, and I'm stuck on an export function.  What I want is to have a mass update function that will take my entire database and dump it into a text file. 

However, my programming isn't working.  I've tried writeln'ing my results, and I'm getting a blank text file.  My sample code below only includes 3 export fields to be easy on the eyes.  Can anyone tell me what I'm missing?

Thanks!
Blair

Code
Select All
var vFileGo as int

FileClose(vFileGo)
FileDelete("C:\export1.txt")
vFileGo = fileopen("c:\export1.txt")
if vFileGo >= 0
{
	fileseek(vFileGo, filesize(vFileGo))
	filewrite(vFileGo, @XLookupSourceListAll(@FN,"=;/=","Client#","Client#;CltGrp;Contact1"))
	fileclose(vFileGo)
}
 

  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Trying to dump database into text file
Reply #1 - Dec 1st, 2006 at 7:49pm
Print Post Print Post  
This is in a mass update? If so, there are all sorts of issues here.

1. The first line is a FileClose. You have not opened a file yet.

2. If this is in a mass update, it runs for each record. This means that you are deleting the file and redumping your entire database for each record.

3. vFileGo is a local variable, so it does not keep it's value as you move from record to record.

...and so on.

This code looks like it dumps the database all at once, but you say you have it in a mass update. This would indicate that you are trying to write the values for each record one at a time. Could you explain what you are trying to do, and when? I'm not sure what to suggest until I know for sure if this is a single record or multi-record process.

Did you take my Integration class? If so, look at the sample code on page 15 of the coursebook.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Trying to dump database into text file
Reply #2 - Dec 1st, 2006 at 8:05pm
Print Post Print Post  
Hi!

I'm trying to dump the whole database into a text file, regardless of the current retrieve spec.  I pasted my FileOpen/FileWrite/etc code from another programming function, so that's why it's schitzophrenic.  I'll fix that.

Basically I'm testing my code in a mass update with an eye towards moving it to a command button on the form.
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Trying to dump database into text file
Reply #3 - Dec 1st, 2006 at 8:24pm
Print Post Print Post  
How often do you need to do this?
What do you do with the resulting text file?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Trying to dump database into text file
Reply #4 - Dec 1st, 2006 at 8:44pm
Print Post Print Post  
I'll need to do this once a week, possibly more.

Actually, what I am doing with the subsequent data (once I get to that point) is having the same command button fire up a @shell with Q&A and importing my data into a Q&A database so my other business modules can effectively communicate with my Sesame data on demand. 

I know it's a one-way communication, but that's all I need right now.  It's temporary until I bring all my business modules online with Sesame.
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Trying to dump database into text file
Reply #5 - Dec 1st, 2006 at 8:56pm
Print Post Print Post  
Try something like this.

Code
Select All
var vFile as Int
var vFileName as String
var vData as String

	vFilename = "c:\sesame\dumpit.txt"
	If FileExists(vFilename)
	{
		FileDelete(vFilename)
	}
	vFile = FileOpen(vFilename)
	If vFile > -1
	{
		FileSeek(vFile, 0)
		vData = @XLookupSourceListAll(@FN, "=;/=", "KEY", "KEY;First;Last")
		If Not @Error
		{
			FileWrite(vFile, vData)
		}
		FileClose(vFile)
	}

 



This sample works with the Customers database. You'll need to change the field names to match yours.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged