0

Is it possible to pass a bind variable to a procedure? Here a simplified snippet, to show what I'm trying to do:

CREATE OR REPLACE PROCEDURE TEST_CSV ( :d1 IN DATE DEFAULT null, :n1 IN NUMBER DEFAULT null)
IS 
BEGIN    
    SELECT DISTINCT * from table WHERE MY_NUM = :n1;    
END;

1 Answer 1

3

I think you've misunderstood how procedures work.

You define a procedure (or function) with parameters, the values of which get passed in from the calling code.

Therefore, you would define the procedure with named parameters, e.g.

CREATE OR REPLACE PROCEDURE TEST_CSV (d1 IN DATE DEFAULT null,
                                      n1 IN NUMBER DEFAULT null)
IS 
BEGIN    
    SELECT DISTINCT * from table WHERE MY_NUM = n1;    
END;
/

and you would call the procedure passing in the values - which could be bind variables, e.g.:

BEGIN
  test_csv (d1 => :d1,
            n1 => :n1);
END;
/
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.