The stored function that takes input custID and returns
city (not code):
create or replace function get_city(cnum in customer.custid%type)
return zipcode.city%type as ccity
zipcodes.city%type;
begin
select city into city from customer.zipcode
where custid = cnum and customer.zip =
zipcode.zip;
return (ccity);
end;
Execute this way SQL>select cno, cname, get_city(custid) from customer;
IF(SELECT COUNT(*)
FROM sales
WHERE itemname = "Orange"
GROUP BY itemname)>3
PRINT 'The custid of customer in the item orange is 4 or more'
ELSE BEGIN
PRINT 'The
following customer who bought the orange'
SELECT FN,
LN
FROM
customer, sales
WHERE
customer.custid = sales.custid
AND
itemname = "Orange"
END