Thomasm
4th April 2006, 11:02
Hello

I have a few systems out there of which some are on SQL Server Level 1 and some are on Level 2. I am now looking for a way to determine if the current system is on level 1 or on level 2, but I need to do it in a script at runtime. Is there a way to do this? Maybe by pulling the data from the tabledef6.1 file with a command similar to the getenv$() function?

Thanks for your help,
/Thomas

Thomasm
4th April 2006, 11:35
Hello again

Actually I continued thinking about this problem and came up with one solution. Maybe it is not the best or even good but it seems to be working for me.

I post the code here if anyone is interested.

/Thomas


| function to determine db level (1 or 2) in the situation where we
| have a choice of Oracle (all are level 2)
| and MSQLSERVER where it can be either level 1 or level 2
| For Baan IV
function determineDBLevel()
{
string local.buffer(256)
string BSE(100)
long file.pointer
long _seq.zero

local.buffer = ""
_seq.zero = 0

select
ttaad410.torg:db.platform
from
ttaad410
where
ttaad410._compnr = 000
as set with 1 rows
selectdo
break | silence compiler
endselect

| if it is oracle we know it is level 2
if db.platform = ttaad.torg.ora8 then
db.level = 2
return
endif

| if not oracle we need to find the settings
BSE = getenv$( "BSE" )

file.pointer = seq.open( strip$(shiftl$(BSE)) & "/lib/tabledef6.1", "rt")

if ( file.pointer < 1 ) then
message("Did not find the file tabledef6.1 to determine the database level.\nContact you system administrator")
return
endif

while _seq.zero = 0
_seq.zero = seq.gets( local.buffer, 256, file.pointer, GETS_ALL_CHARS )
if ( pos(local.buffer, "MSQL_LEVEL1=0") > 0 ) then
db.level = 2
_seq.zero = 9999
else
if ( pos(local.buffer, "MSQL_LEVEL1=1") > 0 ) then
db.level = 1
_seq.zero = 9999
endif
endif

endwhile

_seq.zero = seq.close( file.pointer )

}