Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate Database return code
Message
From
01/10/2004 16:17:33
 
 
To
01/10/2004 08:17:47
Neil Mc Donald
Cencom Systems P/L
The Sun, Australia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00947890
Message ID:
00948074
Views:
20
>Hi,
>Is there a way to get a return code from Validate Database, or is writing the output to disk with the "output to filename and seaching for "Database container is valid" the only way.

I use the following function. You need exclusive access to the database.
function DBCValidate(tcDBase)
local lcDummyDB, ;
	  lcSafety, ;
	  lcOutFile, lcStrOutFile, ;
	  lcOutFileDummy, lcStrOutFileDummy
	  
lcSafety = set('safety')
set safety off

*-- Text fiels that will hold validation output messages
lcOutFile      = addbs(sys(2023)) + sys(2015) + '.txt'
lcOutFileDummy = addbs(sys(2023)) + sys(2015) + '.txt'

*-- Creates a dummy database to generate the validation file. This file
*-- is the compared to the file generated by tcDBase.
*-- The dummy database is created with the same name as the original one
*-- to create the same message.
lcDummyDB = addbs(sys(2023)) + justFName(tcDBase)
create database (lcDummyDB)
validate database to file (lcOutFileDummy) noConsole
close database
delete database (lcDummyDB)

if not DBUsed(tcDBase)
	open database (tcDBase) exclusive
endif
set database to (tcDBase)
close tables

validate database to file (lcOutFile) noConsole

*-- Compares the two messages generated
lcStrOutFile      = fileToStr(lcOutFile)
lcStrOutFileDummy = fileToStr(lcOutFileDummy)
llValid = (lcStrOutFile == lcStrOutFileDummy)

*-- Cleanup
set safety &lcSafety
delete file (lcOutFile)
delete file (lcOutFileDummy)
return llValid
HTH,
Javier.
Previous
Reply
Map
View

Click here to load this message in the networking platform