Hi all!
have a problem.
I have few server accross city with the same database, e.g. like sports db.
the only differences is customer data it contains. Like server with database Sports_1 contains cust-num 1 - 84, database Sports_2 contains cust-num 85-168, etc (but please consider it randomized).
At central server i have a program that will check a cust-num around all servers that I have. within this central server i have a list of all other servers that I have. So for example when someone asked about customer with cust-num 100, first I will check database Sports_1, and because I can't find it there I will try another server that available, in this case Sports_2, n voila. I found it there. If I still can't find it there I will seek Sports_3, Sports_4 and so on until the last sever.
I wrote the code below.
The problem is first the program connect to Sports_1, n run procedure "trial_connect3.p", everything went ok. but when I disconnect Sports_1, connecting to Sports_2, n running file "trial_connect3.p", it still recognise Sports_1 n wont connect to Sports_2. it gives me warning that Sports_1 is not connected.
My question is there any way so that I can "flush" my file "trial_connect3.p" so that it will release Sports_1 and accepting Sports_2. Because it give me a headache because at least I have 4 database around the place.
Regards
YoChan
have a problem.
I have few server accross city with the same database, e.g. like sports db.
the only differences is customer data it contains. Like server with database Sports_1 contains cust-num 1 - 84, database Sports_2 contains cust-num 85-168, etc (but please consider it randomized).
At central server i have a program that will check a cust-num around all servers that I have. within this central server i have a list of all other servers that I have. So for example when someone asked about customer with cust-num 100, first I will check database Sports_1, and because I can't find it there I will try another server that available, in this case Sports_2, n voila. I found it there. If I still can't find it there I will seek Sports_3, Sports_4 and so on until the last sever.
I wrote the code below.
The problem is first the program connect to Sports_1, n run procedure "trial_connect3.p", everything went ok. but when I disconnect Sports_1, connecting to Sports_2, n running file "trial_connect3.p", it still recognise Sports_1 n wont connect to Sports_2. it gives me warning that Sports_1 is not connected.
My question is there any way so that I can "flush" my file "trial_connect3.p" so that it will release Sports_1 and accepting Sports_2. Because it give me a headache because at least I have 4 database around the place.
Regards
YoChan
Code:
/* Trial.p */
FUNCTION Find_DB RETURNS CHAR FORWARD.
DEF VAR vLocal_DB AS CHAR NO-UNDO INIT "".
DEF VAR vCust-Num LIKE customer.cust-num INIT 170.
DEF VAR vFound AS LOGICAL NO-UNDO INIT NO.
PROCEDURE Connection_Check.
DEF INPUT PARAM lvDB_Name AS CHAR.
DEF VAR lvCounter AS INT NO-UNDO INIT 0.
DEF VAR lvFound AS LOGICAL NO-UNDO INIT NO.
DO lvCounter = 1 TO 50 :
IF LDBNAME (lvCounter) = ? THEN LEAVE.
IF LDBNAME (lvCounter) = lvDB_Name THEN DO :
lvFound = YES.
LEAVE.
END.
end.
IF lvFound = YES THEN
MESSAGE "DATABASE " lvDB_NAME " CONNECTED".
ELSE
MESSAGE "DATABASE " lvDB_NAME " NOT CONNECTED".
READKEY.
END.
FUNCTION Find_DB RETURNS CHAR.
DEF VAR lvDB_Group AS CHAR INIT "Sports".
DEF VAR lvCounter AS INT NO-UNDO INIT 0.
DO lvCounter = 1 TO 50 :
IF LDBNAME (lvCounter) = ? THEN LEAVE.
IF INDEX (LDBNAME (lvCounter), lvDB_Group) GT 0 THEN DO :
RETURN (LDBNAME (lvCounter)).
END.
END.
RETURN "".
END.
FOR EACH db_master BY db_master.db_name DESC.
IF db_master.db_name NE vLocal_DB THEN DO:
CONNECT VALUE (db_master.db_path).
RUN "trial_connect3.p" (INPUT vCust-Num, INPUT db_master.db_name, OUTPUT vFound).
DISCONNECT VALUE (db_master.db_name).
IF vFound = YES THEN DO :
MESSAGE "WE HAVE FOUND IT ON OUR DATABASE " + db_master.db_name + "~nWILL LEAVE SHORTLY." VIEW-AS ALERT-BOX.
LEAVE.
END.
END.
END.
IF vFound NE YES THEN DO:
MESSAGE "SORRY, WE CAN'T FIND IT ON ALL OF OUR DATABASES." VIEW-AS ALERT-BOX.
END.
Code:
/* trial_connect3.p */
DEF INPUT PARAM lvCust-Num LIKE customer.cust-num.
DEF INPUT PARAM lvDB_Name LIKE db_master.db_name.
DEF OUTPUT PARAM lvFound AS LOGICAL.
PROCEDURE Connection_Check.
DEF INPUT PARAM lvDB_Name AS CHAR.
DEF VAR lvCounter AS INT NO-UNDO INIT 0.
DEF VAR lvFound AS LOGICAL NO-UNDO INIT NO.
DO lvCounter = 1 TO 50 :
IF LDBNAME (lvCounter) = ? THEN LEAVE.
IF LDBNAME (lvCounter) = lvDB_Name THEN DO :
lvFound = YES.
LEAVE.
END.
end.
IF lvFound = YES THEN
MESSAGE "DATABASE " lvDB_NAME " CONNECTED".
ELSE
MESSAGE "DATABASE " lvDB_NAME " NOT CONNECTED".
READKEY.
END.
RUN Connection_Check("Sports_1").
RUN Connection_Check("Sports_2").
RUN Connection_Check("Sports_3").
FIND FIRST customer WHERE customer.cust-num = lvCust-Num NO-LOCK NO-ERROR.
IF AVAIL customer THEN DO:
MESSAGE "FOUND " + STRING(lvCust-Num) + " ON " + lvDB_Name + " WITH NAME : " + customer.name + ".".
READKEY.
SET lvFound = YES.
RETURN.
END.
ELSE DO:
MESSAGE "NOT FOUND " + STRING(lvCust-Num) + " ON " + lvDB_Name + ".".
READKEY.
SET lvFound = NO.
RETURN.
END.