Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Page 1
Parameterized Cursors
A cursor can take parameters, which can appear in the associated query wherever
constants can appear. The formal parameters of a cursor must be INparameters.
Therefore, they cannot return values to actual parameters. Also, you cannot impose
the constraint NOTNULLon a cursor parameter.
As the example below shows, you can initialize cursor parameters to default values.
That way, you can pass different numbers of actual parameters to a cursor,
accepting or overriding the default values as you please. Also, you can add new
formal parameters without having to change every reference to the cursor.
DECLARE
CURSORc1(lowINTEGERDEFAULT0,
highINTEGERDEFAULT99)ISSELECT...
The scope of cursor parameters is local to the cursor, meaning that they can be
referenced only within the query specified in the cursor declaration. The values of
cursor parameters are used by the associated query when the cursor is opened.
PL-SQL - 3 Cursors
Page 2
PL-SQL - 3 Cursors
ElsIf M.Sal >= 8000 Then
M.Sal := 11000;
ElsIf M.Sal >= 6000 Then
M.Sal := 9500;
ElsIf M.Sal >= 4000 Then
M.Sal := 7500;
Else
M.Sal := 5000;
End If;
Update esal
set sal = M.Sal
Where Current Of cf;
End Loop;
End;
Page 3
PL-SQL - 3 Cursors
Page 4