Remote Procedure Calls Will Get You the CheeseDecember 10, 2002
You see, the door to her cage was activated by a client application that would check Priscilla's computer system time and at 12:00 noon would flash a green light and open the door. What Priscilla didn't know was that the official lunch clock for the rats and putty-tat was maintained within another computer system, and because Simon the system admin never installed any time syncing software on Priscilla's system, her system was always 15 minutes behind.
Well, since last week when Simon got a bit too greedy around lunch time and putty-tat finally got to feed, Priscilla realized her problem of synchronization wasn't going to get solved any time soon. Priscilla decided to fix the problem herself. She would somehow have to change the application that controlled her green light so that it would obtain the system time from the main computer instead of using her own internal system clock.
In a desperate attempt, Priscilla first tried to just select the sysdate by using a database link:
All this did was once again give Priscilla the sysdate from her internal system.
After experimenting for a little while, she realized that in order to get the proper date and time to the application that flashed the green light and opened her cage door, it would have to issue a connect to the LUNCH database. This could only be accomplished through a remote procedure call that would return the date and time. Fortunately, the code was in PL/SQL and Priscilla was an expert at PL/SQL. Priscilla started coding so she could get to lunch sooner.
The first procedure to write was the remote procedure that would reside in the LUNCH database:
This was an easy procedure for Priscilla to write. Nothing she hadn't done many times before. Even though Priscilla is a wise rat and keeps her database upgraded, she knew that there are earlier versions of Oracle around and one of those other rats just might need her code, so she decided to be "version friendly" and compatible for earlier versions of PL*SQL.
The next step was to alter the client application. There was a procedure that pulled the system date and time called CALL_GET_DATE. After a few attempts this is what Priscilla came up with for her local procedure. There's not a great deal different here except she changed the simple SELECT sysdate from dual' with a dynamic procedure build which uses a database link.
As you can see Pricilla was very rushed to get this done, and as a result, she hard coded the dblink name. The twelve o'clock hour was coming up soon, and she didn't want to be late for anymore lunches. When she gets back from lunch with a full belly of cheese and crumbs, she intends to pass this procedure the database link name and also add some error routines.
Bon Appitete
|