0

In Oracle this should be a very simple thing but I only started working with procedures a day ago and I'm having some trouble with this. I created a procedure that's supposed to receive a type of facility as a parameter, say 'healthcare' for instance.

create or replace 
PROCEDURE Adminfacility(
  v_facility_type IN VARCHAR2)
IS
BEGIN
  ...(SELECT goes here)...
END Adminfacility

Is this right? How do I make the procedure receive the parameter and then return a table of two columns? (Facility ID's and respective admins for instance). One problem I'm having is that it requires me to have an INTO after the SELECT statement. I've done something of the kind before with functions where you'd input a numerical ID and receive a number output, but I've never done this kind of thing before.

I've done a similar thing as a view (where it has a default facility type) and it works, but I can't get it to work as a procedure.

1
  • What database are you working with? Dec 2, 2012 at 17:33

1 Answer 1

0
CREATE PROC Adminfacility
@text NVARCHAR(MAX)
AS
BEGIN
   SELECT id,adminname
   FROM TABLE 
   WHERE TEXT =@text    
END

This is accepting text as parameter using it in where condition and then return a table.

if you want to change already existing proc then instead of CREATE write ALTER

1
  • Thanks, I've done something of the kind, however the procedure is requiring me to write an INTO clause after the SELECT statement, I'm not sure what to do here
    – Jaqualembo
    Dec 2, 2012 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.