----- Original Message -----
Sent: Friday, November 04, 2005 10:54
AM
Subject: [RBG7-L] - Re: SATTACH
sample
Jan
Here are two subroutines (7.1) that attach
to another R:Base database, then detach at the end:
----------------------------------------------------------------------------
--
FILENAME
: PAYATTCH.RMD
-- CREATED
BY
: David M. Blocker
-- DATE INITIALLY CREATED : 06/08/03
--
PURPOSE
: Attach ODBC source PAYROLL to PAYDIST
-- CALLED
BY
: PAYACCRU.RMD
-- CALLS
rmds
:
--
forms
: ErrorMessage
--
reports :
--
EXTERNAL VARS REFERENCED:
-- INTERNAL VARS CLEARED :
--
VARIABLES PASSED TO OTHERS: vAttOK: Yes = attached to Payroll, No =
not
--
attached
----------------------------------------------------------------------------
SET ERROR VAR gerrvar
SET VAR vAttOK =
'Yes'
SET VAR fMLine1 = 'Please wait; attaching to Payroll Database and
creating +
copy of Payroll data for maximum report speed. . .'
PAUSE 4
USING .fMLine1 CAPTION .vCaption
SCONNECT PAYROLL IDENTIFIED BY BASSPAY
BASSPAY
IF gerrvar <> 0 THEN
SET VAR fMLine1 = ('Unable to
make ODBC connection to PAYROLL +
database! Call David Blocker and
notify him of this problem immediately! +
Click on OK to
cancel.')
EDIT USING ErrorMessage CAPTION .vCaption
SET
VAR vAttOK = 'No'
GOTO BOTTOM
ENDIF
SATTACH TOTBYID
IF gerrvar <> 0
THEN
SET VAR fMLine1 = ('ODBC connection to PAYROLL database
successful, but +
unable to attach the TotByID view! Call David
Blocker and notify him of this')
SET VAR fMLine1 = (.fMLine1 &
'problem immediately! Click on OK to +
disconnect from PAYROLL and
cancel.')
EDIT USING ErrorMessage CAPTION .vCaption
SDETACH TOTBYID
SDISCONNECT PAYROLL
SET VAR vAttOK =
'No'
GOTO BOTTOM
ENDIF
SATTACH PayRollNum
IF gerrvar <> 0
THEN
SET VAR fMLine1 = ('ODBC connection to PAYROLL database
successful, but +
unable to attach the PayRollNum table! Call David
Blocker and notify him of')
SET VAR fMLine1 = (.fMLine1 & 'this
problem immediately! Click on OK to +
disconnect from PAYROLL and
cancel.')
EDIT USING ErrorMessage CAPTION .vCaption
SDETACH TOTBYID
SDETACH PAYROLLNUM
SDISCONNECT
PAYROLL
SET VAR vAttOK = 'No'
GOTO
BOTTOM
ENDIF
LABEL BOTTOM
CLS
RETURN
----------------------------------------------------------------------------
--
FILENAME
: PAYDETCH.RMD
-- CREATED
BY
: David M. Blocker
-- DATE INITIALLY CREATED : 06/09/03
--
PURPOSE
: Detach ODBC source PAYROLL
-- CALLED
BY
: PAYACCRU.RMD
-- CALLS
rmds
:
--
forms
: ErrorMessage
--
reports :
--
EXTERNAL VARS REFERENCED:
-- INTERNAL VARS CLEARED :
--
VARIABLES PASSED TO OTHERS: vDetOK: Yes = detached from Payroll, No =
not
--
detached
----------------------------------------------------------------------------
SET
ERROR VAR gerrvar
SET VAR vDetOK = 'Yes'
CLS
SET VAR fMline1 = 'Please wait;
discarding Payroll Accrual Reports data. . .'
PAUSE 4 USING .fMLine1
CAPTION .vCaption
SDETACH TOTBYID NOCHECK
IF gerrvar
<> 0 THEN
SET VAR fMLine1 = 'Unable to detach the TotByID view
for some reason! +
Call David Blocker and notify him of this problem
immediately! +
Click on OK to cancel.'
EDIT USING
ErrorMessage CAPTION .vCaption
SET VAR vDetOK = 'No'
GOTO
BOTTOM
ENDIF
SDETACH PAYROLLNUM NOCHECK
IF gerrvar
<> 0 THEN
SET VAR fMLine1 = 'Unable to detach the PayRollNum
view for some reason! +
Call David Blocker and notify him of this problem
immediately! +
Click on OK to cancel.'
EDIT USING
ErrorMessage CAPTION .vCaption
SET VAR vDetOK = 'No'
GOTO
BOTTOM
ENDIF
SDISCONNECT PAYROLL
IF gerrvar <> 0
THEN
SET VAR fMLine1 = 'Unable to CLOSE ODBC connection to PAYROLL
+
database! Call David Blocker and notify him of this problem
immediately! +
Click on OK to cancel.'
EDIT USING
ErrorMessage CAPTION .vCaption
SET VAR vDetOK = 'No'
GOTO
BOTTOM
ENDIF
DISCONNECT
--CLOSEWINDOW
Form1
CLS
CONNECT &vDatabase1
-- DMB 07/31/03
SET MESSAGES
OFF
SET ERROR MESSAGES OFF
LABEL BOTTOM
RETURN
----- Original Message -----
Sent: Friday, November 04, 2005 12:53 PM
Subject: [RBG7-L] - SATTACH sample
Hello all,
Does anyone have a good sample of code using SATTACH and
SCONNECT (and their opposites)?
The help file says that once you issue an SATTACH you don't
need to do it again. How do you manage that in some startup code?
TIA
Jan