How to determine connected database programmatically

Laker Netman

New Member
Hi all,
I almost posted this under the development section, but it's really an admin issue for me. I'm running 9.1d Progress on AIX, supporting MFGPRO eB2. I write and run various maintenance programs periodically, and I was wondering if anyone could provide (if it's possible) a quick query or bit of test code that would tell me which database I'm attached to, so I could decide if I really want the remainder of the program to run. Following QAD recommendations we run Production and Test DBs, and there are things I run against Test that I definitely do not want to inadvertantly run against Production.... not that that has *ever* happened :confused:

Thanks,
Laker
 
note: Not tested on UNIX....as i don't have access to unix right now....

Code:
&SCOPED-DEFINE ProdSystems "AAA,BBB,CCC"

DEFINE VARIABLE cSysName  AS CHARACTER FORMAT "x(50)" NO-UNDO.
DEFINE VARIABLE iDbCount  AS INTEGER                  NO-UNDO. 

OS-COMMAND SILENT uname -n > version.txt. 
INPUT FROM version.txt. 
DO WHILE TRUE: 
   IMPORT UNFORMATTED cSysName. 
   IF cSysName NE "" THEN 
       MESSAGE cSysName VIEW-AS ALERT-BOX INFORMATION. 
END. 
INPUT CLOSE.

IF LOOKUP(cSysName,{&ProdSystems}) > 0 THEN
DO:
    MESSAGE 'Cannot execute this script.' SKIP
            'You are on Production Box !!!'
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
    RETURN NO-APPLY.
END.

REPEAT iDbCount = 1 TO NUM-DBS:  
    DISPLAY LDBNAME(iDbCount) PDBNAME(iDbCount).
END.
 
Back
Top