project BLF > class BApplicationProperty > method APIGetConnectedDatabases
Description
Get the list of connected databases, together with information about current status and startup.
Parameters
Internal usage
unused
program code (program3/bapplicationproperty.p)
&scoped ATTR-GET-FUNC ~
create tDatabaseInfo.~
assign tDatabaseInfo.tcDbPropertyName = trim(~{~&ATTR-NAME~})~
tDatabaseInfo.tiDatabaseId = viCount1~
tDatabaseInfo.tcDbPropertyType = "~{~&ATTR-TYPE~}":U~
tDatabaseInfo.tcDbPropertyValue = ~{~&ATTR-TYPE~}(viCount1).
&scoped ATTR-GET-FIELD ~
create tDatabaseInfo.~
assign vhFld = vhBuf:buffer-field("~{~&ATTR-TYPE~}":U)~
tDatabaseInfo.tcDbPropertyName = trim(~{~&ATTR-NAME~})~
tDatabaseInfo.tiDatabaseId = viCount1~
tDatabaseInfo.tcDbPropertyType = "~{~&ATTR-TYPE~}":U~
tDatabaseInfo.tcDbPropertyValue = vhFld:buffer-value.
&scoped ATTR-GET-CONN ~
create tDbConnectionInfo.~
assign vhFld = vhBuf:buffer-field("_Connect-~{~&ATTR-TYPE~}":U)~
tDbConnectionInfo.tcDbConnName = trim(~{~&ATTR-NAME~})~
tDbConnectionInfo.tiDatabaseId = viCount1~
tDbConnectionInfo.tiDbConnId = viFcCount2~
tDbConnectionInfo.tcDbConnType = "~{~&ATTR-TYPE~}":U~
tDbConnectionInfo.tcDbConnValue = vhFld:buffer-value.
assign oiReturnStatus = -98.
empty temp-table tDatabaseInfo.
empty temp-table tDbConnectionInfo.
/* ========================================= *
* DATABASES & CONNECTIONS
* ========================================= */
define variable vcStr as character no-undo.
define variable vhFld as handle no-undo.
define variable vhBuf as handle no-undo.
define variable vhQry as handle no-undo.
do viCount1 = 1 to num-dbs:
if dbtype(viCount1) <> "Progress"
then next.
&scoped ATTR-TYPE LDBNAME
&scoped ATTR-NAME #T-1'Logical Database Name':60(137)t-1#
{&ATTR-GET-FUNC}
&scoped ATTR-TYPE DBPARAM
&scoped ATTR-NAME #T-2'Database Connection Parameters':60(138)t-2#
{&ATTR-GET-FUNC}
/* ========================================= *
* PDBNAME
* ========================================= */
vcStr = ldbname(viCount1) + "._areaextent":U.
create buffer vhBuf for table vcStr in widget-pool "non-persistent".
create query vhQry in widget-pool "non-persistent".
vhQry:add-buffer(vhBuf).
vhQry:query-prepare( subst("for each &1 where _extent-type = 1 no-lock":U, vcStr)).
vhQry:query-open().
&scoped ATTR-TYPE PDBNAME
&scoped ATTR-NAME #T-3'Physical Database Name':60(139)t-3#
create tDatabaseInfo.
assign tDatabaseInfo.tcDbPropertyName = trim({&ATTR-NAME})
tDatabaseInfo.tiDatabaseId = viCount1
tDatabaseInfo.tcDbPropertyType = "{&ATTR-TYPE}":U.
if vhQry:get-first()
then assign vhFld = vhBuf:buffer-field("_extent-path":U)
tDatabaseInfo.tcDbPropertyValue = vhFld:buffer-value.
else assign tDatabaseInfo.tcDbPropertyValue = PDBNAME(viCount1).
vhQry:query-close().
delete widget vhQry.
delete widget vhBuf.
/* ========================================= *
* DBSTATUS
* ========================================= */
vcStr = ldbname(viCount1) + "._DbStatus":U.
create buffer vhBuf for table vcStr in widget-pool "non-persistent".
create query vhQry in widget-pool "non-persistent".
vhQry:add-buffer(vhBuf).
vhQry:query-prepare( subst("for each &1 no-lock":U, vcStr)).
vhQry:query-open().
vhQry:get-first().
&scoped ATTR-TYPE _DbStatus-AiBlkSize
&scoped ATTR-NAME #T-4'After image block size (bytes)':60(140)t-4#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-BiBlkSize
&scoped ATTR-NAME #T-5'Before image block size (bytes)':60(141)t-5#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-BiClSize
&scoped ATTR-NAME #T-6'Before image cluster size (kb)':60(142)t-6#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-BiOpen
&scoped ATTR-NAME #T-7'Most recent .bi file open':60(143)t-7#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-BiSize
&scoped ATTR-NAME #T-8'Logical .bi file size':60(144)t-8#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-BiTrunc
&scoped ATTR-NAME #T-9'Time Since Last Truncate .bi':60(145)T-9#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-CacheStamp
&scoped ATTR-NAME #T-10'Local cache file time stamp':60(146)t-10#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-Changed
&scoped ATTR-NAME #T-11'Sequence of last incremental':60(147)t-11#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-ClVersMinor
&scoped ATTR-NAME #T-12'Client minor version number':60(148)t-12#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-Codepage
&scoped ATTR-NAME #T-13'Database Character Set':60(149)t-13#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-Collation
&scoped ATTR-NAME #T-14'Database Collation Name':60(150)t-14#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-CreateDate
&scoped ATTR-NAME #T-15'Database created (multi-volume)':60(151)t-15#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-DbBlkSize
&scoped ATTR-NAME #T-16'Database block size':60(152)t-16#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-DbVers
&scoped ATTR-NAME #T-17'Database version number':60(153)t-17#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-DbVersMinor
&scoped ATTR-NAME #T-18'Database minor version number':60(154)t-18#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-EmptyBlks
&scoped ATTR-NAME #T-19'Empty blocks':60(155)t-19#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-fbDate
&scoped ATTR-NAME #T-20'Most recent full backup':60(156)t-20#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-FreeBlks
&scoped ATTR-NAME #T-21'Free blocks':60(157)t-21#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-HiWater
&scoped ATTR-NAME #T-22'Database Blocks High Watermark':60(158)T-22#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-ibDate
&scoped ATTR-NAME #T-23'Most recent incremental backup':60(159)t-23#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-ibSeq
&scoped ATTR-NAME #T-24'Sequence of last incremental':60(147)t-24#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-Integrity
&scoped ATTR-NAME #T-25'DB Status Integrity':60(160)T-25#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-IntFlags
&scoped ATTR-NAME #T-26'Integrity flags':60(161)t-26#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-LastOpen
&scoped ATTR-NAME #T-27'Most recent database open':60(162)t-27#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-LastTable
&scoped ATTR-NAME #T-28'Highest table number defined':60(163)t-28#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-LastTran
&scoped ATTR-NAME #T-29'Last transaction id':60(164)t-29#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-Misc
&scoped ATTR-NAME #T-30'Misc':60(165)t-30#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-MostLocks
&scoped ATTR-NAME #T-31'Lock Table High Watermark':60(166)T-31#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-NumAreas
&scoped ATTR-NAME #T-32'Number of areas':60(167)t-32#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-NumLocks
&scoped ATTR-NAME #T-33'Lock table entries in use':60(168)t-33#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-NumSems
&scoped ATTR-NAME #T-34'Number of semaphores used':60(169)t-34#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-PrevOpen
&scoped ATTR-NAME #T-35'Previous database open':60(170)t-35#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-RMFreeBlks
&scoped ATTR-NAME #T-36'RM Blocks with Free Space':60(171)T-36#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-SharedMemVer
&scoped ATTR-NAME #T-37'Shared Memory Version #':60(172)t-37#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-ShmVers
&scoped ATTR-NAME #T-38'Shared memory version number':60(173)t-38#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-starttime
&scoped ATTR-NAME #T-39'Database was started at':60(174)t-39#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-state
&scoped ATTR-NAME #T-40'Database state':60(175)t-40#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-tainted
&scoped ATTR-NAME #T-41'Database damaged flags':60(176)t-41#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _DbStatus-TotalBlks
&scoped ATTR-NAME #T-42'Number of blocks allocated':60(177)t-42#
{&ATTR-GET-FIELD}
vhQry:query-close().
delete widget vhQry.
delete widget vhBuf.
/* ========================================= *
* DBSTARTUP
* ========================================= */
vcStr = ldbname(viCount1) + "._Startup":U.
create buffer vhBuf for table vcStr in widget-pool "non-persistent".
create query vhQry in widget-pool "non-persistent".
vhQry:add-buffer(vhBuf).
vhQry:query-prepare( subst("for each &1 no-lock":U, vcStr)).
vhQry:query-open().
vhQry:get-first().
&scoped ATTR-TYPE _Startup-AiBuffs
&scoped ATTR-NAME #T-43'Number of after image buffers (-aibufs)':60(178)t-43#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-AiName
&scoped ATTR-NAME #T-44'After Image File Name (-a)':60(179)T-44#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-APWBuffs
&scoped ATTR-NAME #T-45'APW Buffers to Scan':60(180)T-45#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-APWMaxWrites
&scoped ATTR-NAME #T-46'APW Max Writes/Scan':60(181)T-46#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-APWQTime
&scoped ATTR-NAME #T-47'APW queue check time':60(182)t-47#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-APWSTime
&scoped ATTR-NAME #T-48'APW scan time':60(183)t-48#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-BiBuffs
&scoped ATTR-NAME #T-49'Number of before image buffers (-bibufs)':60(184)t-49#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-BiDelay
&scoped ATTR-NAME #T-50'Delay of Before Image Flush (-Mf)':60(185)T-50#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-BiIO
&scoped ATTR-NAME #T-51'Before Image File I/O (-r -R)':60(186)T-51#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-BiName
&scoped ATTR-NAME #T-52'Before Image File Name (-g)':60(187)T-52#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-BiTrunc
&scoped ATTR-NAME #T-53'Before Image Truncate Interval (-G)':60(188)T-53#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-Buffs
&scoped ATTR-NAME #T-54'Number of database buffers (-B)':60(189)t-54#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-CrashProt
&scoped ATTR-NAME #T-55'No crash protection (-i)':60(190)t-55#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-Directio
&scoped ATTR-NAME #T-56'Started with -directio option':60(191)t-56#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-LockTable
&scoped ATTR-NAME #T-57'Current size of locking table (-L)':60(192)t-57#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-MaxClients
&scoped ATTR-NAME #T-58'Maximum number of clients per server (-Ma)':60(193)t-58#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-MaxServers
&scoped ATTR-NAME #T-59'Maximum number of servers (-Mn)':60(194)t-59#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-MaxUsers
&scoped ATTR-NAME #T-60'Maximum number of users (-n)':60(195)t-60#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-Misc
&scoped ATTR-NAME #T-61'Misc':60(165)t-61#
{&ATTR-GET-FIELD}
&scoped ATTR-TYPE _Startup-Spin
&scoped ATTR-NAME #T-62'Spinlock tries before timeout':60(196)t-62#
{&ATTR-GET-FIELD}
vhQry:query-close().
delete widget vhQry.
delete widget vhBuf.
/* ========================================= *
* CONNECTIONS
* ========================================= */
vcStr = ldbname(viCount1) + "._connect":U.
create buffer vhBuf for table vcStr in widget-pool "non-persistent".
create query vhQry in widget-pool "non-persistent".
vhQry:add-buffer(vhBuf).
vhQry:query-prepare( subst("for each &1 where &1._connect-type > '' no-lock":U, vcStr)).
vhQry:query-open().
vhQry:get-first().
assign viFcCount2 = 0.
do while not vhQry:query-off-end:
assign viFcCount2 = viFcCount2 + 1.
&scoped ATTR-TYPE Type
&scoped ATTR-NAME #T-63'Connection Type':60(197)t-63#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE Name
&scoped ATTR-NAME #T-64'User':60(198)t-64#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE Device
&scoped ATTR-NAME #T-65'Connection Device':60(199)t-65#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE Time
&scoped ATTR-NAME #T-66'Connect Time':60(200)t-66#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE Pid
&scoped ATTR-NAME #T-67'Process ID':40(27)T-67#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE Server
&scoped ATTR-NAME #T-68'Server':60(202)t-68#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE TransId
&scoped ATTR-NAME #T-69'Transaction ID':20(5035)T-69#
{&ATTR-GET-CONN}
&scoped ATTR-TYPE Batch
&scoped ATTR-NAME #T-70'Batch client':60(124)t-70#
{&ATTR-GET-CONN}
vhQry:get-next().
end.
vhQry:query-close().
delete widget vhQry.
delete widget vhBuf.
end.
&undefine ATTR-TYPE
&undefine ATTR-NAME
&undefine ATTR-GET-FUNC
&undefine ATTR-GET-FIELD
&undefine ATTR-GET-CONN
assign oiReturnStatus = 0.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BApplicationProperty".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "APIGetConnectedDatabases".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.