Expert

22-19.

Write a package that manages communication through a private pipe named “invasions”. Each message in the pipe contains the information as specified by the following query:

SELECT country, date_of_invasion, people_killed
  FROM invasions
 WHERE (invader IN ('USA', 'CHINA', 'GERMANY', 'SOVIET UNION')
   AND date_of_invasion > '01-JAN-1900';

Features of this package should include the following:

  • The user never specifies or knows the name of the pipe; it is hidden to avoid any spelling mistakes and to ensure consistency.

  • It create the pipe automatically when a session tries to use the pipe.

  • The list is a long one (including, for example, Grenada, Poland, Nicaragua, Vietnam, Chile, France, Tibet, Norway, El Salvador, and Iraq), so set the initial pipe size to at least 2 MB.

  • It waits up to 10 seconds to get or send the information.

Here is the package specification; you write the body:


/* Filename on web page: invasions.pkg */
CREATE OR REPLACE PACKAGE invasion
IS
   TYPE inv_rectype IS RECORD (
      country IN invasions.country%TYPE,
      date_of_invasion invasions.date_of_invasion%TYPE,
      people_killed invasions.people_killed%TYPE
      );

   PROCEDURE sendinfo (
      country IN VARCHAR2,
      date_of_invasion DATE,
      people_killed NUMBER
      );

   PROCEDURE sendinfo (rec IN inv_rectype);

   FUNCTION nextinfo RETURN inv_rectype;
END;
/

22-20.

How can you can obtain a list of all the currently defined database pipes to which you have ...

Get Oracle PL/SQL Programming: A Developer's Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.