Pervasive Looping through Variables

I'm questioning if there is a way in Pervasive to loop through a text file of a single record. Say for instance i have ID's in a txt file that i would like updated. I guess the best way to describe it is much like how you would loop through a txt file in a Windows Batch file.

Is there something like UPDATE table SET column = 'this' WHERE id = '@txt_file_here.txt';

It would then loop through how many records i have. I know i can inject it into a dummy database and run the update that way just trying to save a few steps.
Who is Participating?
Bill BachConnect With a Mentor PresidentCommented:
Pervasive is just a database, and the core tools, while powerfuyl, will not allow something like what you want.  However, you CAN still create a script, using the following method:

This assumes that the "ID" file is called IDFILE.TXT and that it contains ONLY the ID fields that you want to update, exactly one ID per line.
1) Go to and download the free MakeBat tool.
2) Run the following from a command prompt (on one line, of course):
MAKEBAT "UPDATE table SET column = 'this' WHERE id = '" "';" <IDFILE.TXT >IDUPDATE.SQL
3) Load the IDUPDATE.SQL file into the Pervasive Control Center and select "Execute all SQL statements".
4) Set back and watch your computer do your work for you!

The trick is in the MAKEBAT function, which prepends a prefix and appends a suffix onto each line from the input file (in this case, your ID file).  The result is then captured to the SQL file with the ">" redirection function of the command prompt.  This then gives you a single file script which you can load into Pervasive and run automatically.

If needed, massage the text in the double-quotes in the MAKEBAT command line to get the exact SQL statement you need to run.

The tool SQLExec (from the same site) can also automate the running of the SQL script, so that you can do all of this from a single batch file -- and never have to look at it again.

There's no way to do that directly in Pervasive.  You'd need to write (or use) a program that could read the text file and fill in the variable value.  
GalaxiePeteAuthor Commented:
This is great thanks, yeah MySQL has a command for loading direct text files in this same way. This is great, thanks so much.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.