Oracle: procedures+functions code base not overlapping package body code base
Your search will have to be more complicated.  Stored code can be in the package header which is not done that often.  Most often it is in PACKAGE BODY.  If you modified your query to read

SELECT DISTINCT name, type FROM all_source WHERE UPPER(text) 
LIKE UPPER(‘%string%’) and type ='PACKAGE BODY';


This gives all the code that meets your criteria in package bodies.  The line number is all you can get out of all_source.  The fields available in all_source are

OWNER VARCHAR2(30)     Owner of the object 
NAME  VARCHAR2(30)     Name of the object 
TYPE  VARCHAR2(12)     Type of object: FUNCTION, JAVA SOURCE, PACKAGE,PACKAGE BODY, PROCEDURE, TRIGGER, TYPE, TYPE BODY 
LINE  NUMBER           Line number of this line of source 
TEXT  VARCHAR2(4000)   Text source of the stored object 


When you search for type PROCEDURE or FUNCTION you are looking at the stand alone code blocks that are not part of a package.

If the style of coding includes local procedures or functions within procedures or functions in a package body this could get complicated fast. You could look for the mandatory syntax that precedes a code block:  PROCEDURE  xxx or FUNCTION xx is and the code that ends it END ;

So your search would be:


find all procedure or function names in a package or package body and the line number
find the line number of the text you are looking for
write some logic to find the name of the code block that contains the text


Or you could use a GUI tool like TOAD or SQL Developer which will do this for you.