Solved

Pervasive Looping through Variables

Posted on 2008-10-01
3
491 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

756 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