Solved

Pervasive Looping through Variables

Posted on 2008-10-01
3
437 Views
Last Modified: 2013-11-15
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.
0
Comment
Question by:GalaxiePete
3 Comments
 
LVL 18

Expert Comment

by:mirtheil
ID: 22617100
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.  
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 22619288
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 www.goldstarsoftware.com/tools.asp 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.

0
 

Author Comment

by:GalaxiePete
ID: 22682293
This is great thanks, yeah MySQL has a command for loading direct text files in this same way. This is great, thanks so much.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now