'Connecting to Multiple Progress Database using single .p file

Is there a way to connect to multiple progress database. In current situation what we do is we use multiple .p files to fetch the data. Example: 1st program will fetch the data from customer database and using a run command we use to connect to 2nd database. 2nd program we use input parameter to map the value.

My question is, is there a way we can do this in one single program? Below is the sample program:

/*FIRST Program***/  

FIND FIRST customer WHERE customer.cust-id EQ "v456" NO-LOCK NO-ERROR. IF AVAILABLE customer THEN RUN /HOME/dbconnect.p(INPUT customer.cust-id, "ACCOUNTS"). RUN /HOME/program-2.p (INPUT customer.cust-id).

/Second Program**/ DEFINE INPUT PARAMETER ipcCust-id AS CHARACTER.

FOR EACH billing WHERE billing.cust-id EQ ipcCust-id NO-LOCK: DISPLAY billing.DATE. END.



Solution 1:[1]

Is connecting dynamically (inside the .p) a requirement ? If not, it's probably easier to just connect the databases when launching the program...

(I'm on windows, but should be recognizable)

prowin -pf <path-to>\connect.pf -p <path-to>\program.p

where connect.pf contains:
-db <connection settings for db 1>
-db <connection settings for db 2>
<...>

Solution 2:[2]

With static queries, no. You always need to have the database connected before running the .p. With dynamic queries, since there is no reference to the database in the r-code, you can do whatever you want from a single .p.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MightyBarto
Solution 2 Stefan Drissen