[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Pervasive Looping through Variables

Posted on 2008-10-01
3
Medium Priority
?
522 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

656 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