with Dbms, Dbms_Date, Parts_Inventory_Database, Date_Format_Template, Text_Io; procedure Query is Parts_Information : Parts_Inventory_Database. Data_Record_Description; package Date_Formatter is new Date_Format_Template (Month => Dbms_Date.Month, Day => Dbms_Date.Day, Year => Dbms_Date.Year); use Date_Formatter; ----------------------------------------------------------------------- -- This function is used for the Conditional_Part_Query instance. ----------------------------------------------------------------------- function Conditional_Part_Criterion return Boolean is use Parts_Inventory_Database; begin return Parts_Inventory_Database.Is_The_Quantity >= 10; end Conditional_Part_Criterion; procedure Print_Parts_Information (Parts_Information : in Parts_Inventory_Database. Data_Record_Description) is begin Text_Io.Put (String (Parts_Information.The_Part_Number)); Text_Io.Put (' '); Text_Io.Put (String (Parts_Information.The_Customer_Number)); Text_Io.Put (Parts_Inventory_Database.Quantity'IMAGE ( Parts_Information.The_Quantity)); Text_Io.Put (' '); Text_Io.Put_Line (Is_Long_Date (From_Month => Parts_Information.The_Date.The_Month, From_Day => Parts_Information.The_Date.The_Day, From_Year => Parts_Information.The_Date.The_Year)); end Print_Parts_Information; --------------------------------------------------------------------- -- Dave, note the effects of different instantiations of the query. -- When I create my instance, I instantiate with a function that -- tells what it means for a record to be "found." In this way, -- I can write a generalized query and let clients fill in the -- found information. --------------------------------------------------------------------- package Part_Query is new Parts_Inventory_Database.Customers_To_Part_Query_Template; package Conditional_Part_Query is new Parts_Inventory_Database.Customers_To_Part_Query_Template (Is_Match => Conditional_Part_Criterion); begin Dbms.Impart; Parts_Inventory_Database.Open; Text_Io.Put_Line ("Database record for 00000001 01234565"); Parts_Inventory_Database.Find_Inventory_Record (For_Part_Number => "00000001", For_Customer_Number => "01234565"); Print_Parts_Information (Parts_Inventory_Database.Is_Current_Record); Part_Query_Test: begin Text_Io.Put_Line ("Customers Desiring Part 00000001"); Part_Query.Initialize_Query (For_Part => "00000001"); loop Part_Query.Find_Next; Print_Parts_Information (Parts_Inventory_Database.Is_Current_Record); end loop; exception when Parts_Inventory_Database.End_Of_Data => null; end Part_Query_Test; Conditional_Part_Query_Test: begin Text_Io.Put_Line ("Customers Desiring Part 00000001 in Quantities >= 10"); Conditional_Part_Query.Initialize_Query (For_Part => "00000001"); loop Conditional_Part_Query.Find_Next; Print_Parts_Information (Parts_Inventory_Database.Is_Current_Record); end loop; exception when Parts_Inventory_Database.End_Of_Data => null; end Conditional_Part_Query_Test; Parts_Inventory_Database.Close; Dbms.Depart; end Query;