Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable number of arguments in PL/SQL stored procedure

Can a procedure PL/SQL take a variable number of arguments?

In my case, the procedure is called by the submit button of a form, and the form has variable number of inputs.

like image 288
Moltes Avatar asked May 30 '11 17:05

Moltes


People also ask

How many parameters a stored proc can have?

A procedure can have a maximum of 2100 parameters; each assigned a name, data type, and direction. Optionally, parameters can be assigned default values.

How many parameter values a function can take in PL SQL?

The three parameter modes are IN (the default), OUT , and IN OUT . Any parameter mode can be used with any subprogram.

How many parameters can be passed to a stored procedure in Oracle?

The three parameter modes, IN (the default), OUT , and IN OUT , can be used with any subprogram.

What are the 3 modes of parameter in PL SQL?

PL/SQL procedure parameters can have one of three possible modes: IN, OUT, or IN OUT. PL/SQL function parameters can only be IN. An IN formal parameter is initialized to the actual parameter with which it was called, unless it was explicitly initialized with a default value.


2 Answers

You don't mention it, but are you using mod_plsql?

If so, you should read about flexible parameter passing.

In short, prefix your procedure name with an exclamation mark in your browser and define your procedure with a name_array and value_array.

like image 197
Martin Schapendonk Avatar answered Sep 22 '22 08:09

Martin Schapendonk


Sort of. You can give the procedure parameter default values:

CREATE PROCEDURE myproc( p_value_a NUMBER DEFAULT 1, 
                         p_value_b NUMBER DEFAULT 2 ) AS
    ...

which you could call like this:

myproc( 999 );

or like this:

myproc (p_value_b => 11 );
like image 32
eaolson Avatar answered Sep 20 '22 08:09

eaolson