Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically retrieve database VALIDATE status 2

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Dear Team,

Is there any way to check/retrieve database validation status (ie result of VALIDATE DATABASE command) programmatically,
at least was it successful or not.

Thanks
Rajesh karunakaran
 
Well, read about the command. You can do [tt]VALIDATE DATABASE NOCONSOLE TO FILE Filename[/tt] and it works silent and puts any error messages in the file you specify.

Bye, Olaf.
 
Rajesh,

Just to amplify Olaf's reply ....

You say you want to retrieve the validation status: "at least was it successful or not". If the validation is successful, the output from VALIDATE DATABASE contains the words "Database container is valid" (without the quotes). So you could write a little function, like so:

Code:
FUNCTION IsDatabaseValid
* Returns .T. if the database is valid.
* Assumes the database is open and is the current database

LOCAL llValid, lcText

VALIDATE DATABASE NOCONSOLE TO FILE "c:\temp\valid.txt"
lcText = FILETOSTR("c:\temp\valid.txt")
llValid = AT("Database container is valid", lcText) > 0
RETURN llValid

Note that I haven't tested this, but I think it should work as expected.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Tested with Northwind.dbc this works as is. Just read the help about VALIDATE DATABASE please, the DBC has to be opened exclusive, so such a test is not practical in a multi user environment.

Bye, Olaf.
 
Dear Mike/Olaf,

Thank you very much (especially to Mike for taking time to provide that code).
I have already done that idea of looking for 'Database container is valid' string in the file
but was wondering if there could be a way, say to get details in an object or so!

Hope for a day when I also can be of help to someone!
Thank you so much for your time!
Rajesh Karunakaran
 
Dear all,

How can I close this thread? I believe, I have the possible answers for this thread.
Isn't it possible to close it myself?

Thanks
Rajesh Karunakaran
 
No, there is no mechanism for closing a thread*. But it's good that you have posted a message saying that you are happy with the answers you have received. That should act as a signal that you consider the problem solved and that no further replies are necessary.

(*In fact, I think threads get closed automatically after six months.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You can mark helpful answers by clicking "Great post!", that's also a sign to us you got a good answer. You can still continue anyway, the closing of threads for further posts is done automatically just by time, as Mike said. Not sure about the age it needs, but it's beyond the lifetime of a typical thread anyway.

> to get details in an object or so!
What do you mean? Get details on which object (table, index) was tested?
If there is nothing missing you don't get messages. If there is a problem, it will mention what table or index. So you get all info you need. When there is no error all database objects are found. Notice a database validation is only validating the presence of files and indexes, it is not validating each table and even less so each record. If you want that, you'd have to do something like that on your own.

VALIDATE DATABASE has no better way of result in form of meta data, xml or tracelog, as VFP it is intended for developer use at design time. Everything needing exclusive access to files is not for production use, if at all for an administrative tool. If you intend to VALIDATE DATABASE at start of your application, this will be exclusive to the first user of the day in a multi user environment. If it's a web app, there is no such thing as a first user, though. If you have frequent database corruptions you better plan to migrate your data to a more stable backend like MS SQL Server.

Bye, Olaf.
 
Dear Mike,

Thank you! It's okay. I was just checking if it can be closed once I have the answers.

Dear Olaf,

Thank you for the detailing. I have already marked those initial answers 'Great post'!
As of object, you are correct, I was thinking it wrongly. VALIDATE in fact generates the result in great detail (of course, if there are problems with DB). Too, I don't have any such issues as you were trying to visualise. The things are okay.

Thank you once again,
Rajesh Karunakaran
 
Well, if you wanted to mark posts as great post, that didn't get through. Tek-tips creates a pop up asking you to confirm your action. If you use a pop up blocker, you need to add tek-tips as an exception.

Bye, Olaf.
 
I did get the popup to confirm and I confirmed it. But, after that I did not click on the 'Close' link, instead directly closed the popup by clicking on the close icon ('x' mark). Not sure, why it didn't get through!

Rajesh Karunakaran
 
AFAIK after confirmation you can close the popup in any way. The site currently is under heave construction, though it doesn't seems so, and so it might just have been a temporary quirk.

More important, thanks for asking about the forum use, too.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top