-----------------------------------------------------------------
-- PL/SQL: Stored Function (Example 4.4.5)                      -
-- Chapter 4; Oracle Programming -- A Primer                    -
--            by R. Sunderraman                                 -
-----------------------------------------------------------------

create or replace function get_city(
      cnum in customers.cno%type) 
    return zipcodes.city%type as

  ccity zipcodes.city%type;

begin
  select city 
  into   ccity
  from   customers,zipcodes
  where  cno = cnum and
         customers.zip = zipcodes.zip;
  return (ccity);
end;
/
