I have procedure like this:
Procedure(var1 IN VARCHAR2, var2 IN VARCHAR2 ... )
---lines of code---
---inside this procedure i want to d开发者_如何学编程o the below
var1 := filter(var1); -- filter & assign to the same variable
....
....
--do something with var1
But the problem is am not able to modify a IN parameter to a procedure as its a constant. The only option i can think of is to create/declare a new local variable & assign it the modified IN parameter & use it in the subsequent code. But this is leading to clumsy code as there are nearly 30 IN parameters.So i need to create 30 new variables for each of them.
Need your help to change the IN parameter in a plsql procedure OR any other workaround to the above problem.
Regards Vj
The problem is that you're trying to pass var1 as an OUT param into your filter function, which isn't allowed. The only options you have are:
- Make it an IN OUT parameter
- Assign it to a local variable
If you want to modify var1, you will have to change the procedure specification to:
Procedure(var1 IN OUT VARCHAR2 ...
However, you said that there are nearly 30 IN parameters. If the data is related, why not create a custom record type?
-- use CREATE OR REPLACE if at the schema level
CREATE TYPE my_params_type IS RECORD(var1 type, var2 type ...);
Then your procedure...
Procedure(params IN my_params_type) IS
filtered_params my_params_type := params;
BEGIN
filterd_params.var1 := filter(params.var1);
...
something like that
精彩评论