PL / SQL:在Cursor之前初始化变量值

时间:2018-01-11 09:01:36

标签: oracle plsql

是否可以在Cursor声明之前初始化变量值?

我的要求是将值传递给Cursor,这是通过调用另一个函数获得的。

Function SomeFunction(Param1, Param2) Is

SomeParam := fn_findSomeParamValue(Param1,Param2); //This is giving compilation error

Cursor C1 is
select * from SomeTable where SomeColumn = SomeParam;

1 个答案:

答案 0 :(得分:1)

你可以这样做:

Function SomeFunction(Param1, Param2) Is

Cursor C1(someparam <datatype>) is
select * from SomeTable where SomeColumn = SomeParam;

someparam <datatype>;

begin

SomeParam := fn_findSomeParamValue(Param1,Param2); //This is giving compilation error

--Pass it as parameter to cursor
Open C1(someparam);

...
...
end;