Description
Connect a database
Parameters
icDB | input | character | Physical database name. |
icConnect | input | character | Connect parameters |
ihClass | input | handle | Handle to the class that is using the persistence layer. In most of the cases, this handle will be available in the preprocessor {&TARGETPROCEDURE}. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program2/progress.p)
if lookup ("-ld":U,icConnect," ":U) = 0
then assign vcLDBname = entry(num-entries(icDB,"/":U),icDB,"/":U)
vcLDBName = entry(num-entries(vcLDBName,"~\":U),vcLDBName,"~\":U)
vcLDBName = entry(1,vcLDBName,".":U).
else assign vcLDBname = entry(lookup ("-ld":U,icConnect," ":U) + 1,icConnect," ":U).
if index (icConnect," -U ":U) = 0
then do:
<M-3 run MainBlock
(input vcLDBname (icLogicalDbName),
output vcUserId (ocLogin),
output vcPassword (ocPassword)) in dbinfo>
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
if vcUserId <> ""
then assign icConnect = icConnect + " -U ":U + vcUserId.
if vcPassword <> ""
then assign vcConnectDisp = icConnect + " -P ":U + fill("*":U,random(4,9))
icConnect = icConnect + " -P ":U + vcPassword.
end.
error-status:error = no.
/* Incorrect database name causes a progress stop condition. */
if not connected (vcLDBname)
then do transaction on stop undo, leave on error undo, throw:
assign vlFcOk = no.
connect value(icDB) value(icConnect).
assign vlFcOk = yes.
catch syster as progress.lang.syserror:
do viFcCount1 = 1 to syster:NumMessages:
vcErrorList = vcErrorList + "," + string(syster:GetMessageNum (viFcCount1)).
vcMessageList = vcMessageList + "," + syster:GetMessage (viFcCount1).
end.
end catch.
end.
if error-status:error
then do viFcCount1 = 1 to error-status:num-messages:
/* Collect errors, skip duplicates */
if not can-do(vcErrorList,string(error-status:get-number(viFcCount1)))
then assign vcErrorList = vcErrorList + ",":U
+ string(error-status:get-number(viFcCount1))
vcMessageList = vcMessageList + chr(10)
+ error-status:get-message(viFcCount1)
+ " (":U
+ string(error-status:get-number(viFcCount1))
+ ")":U.
end.
if vlFcOk = no
then do:
<M-5 run ErrorMessage
(input #T-3'Unable to connect to database $1 with parameters $2.':255(87)T-3# (icMessage),
input icDB + chr(2) + (if vcConnectDisp = '' then icConnect else vcConnectDisp) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input '' (icRowid),
input ? (ihClass)) in Progress>
<M-68 run ErrorMessage
(input vcMessageList (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input '' (icRowid),
input ? (ihClass)) in Progress>
assign oiReturnStatus = -5.
return.
end.
if dbtype(vcLDBname) <> "PROGRESS":U
then assign vlProgress = no.