Updating salary for different departments using cursor mein fickdate Göttingen
For example, When you execute INSERT, UPDATE, or DELETE statements the cursor attributes tell us whether any rows are affected and how many have been affected. INTO statement is executed in a PL/SQL Block, implicit cursor attributes can be used to find out whether any row has been returned by the SELECT statement. The status of the cursor for each of these attributes are defined in the below table.
In the above PL/SQL Block, the salaries of all the employees in the ‘employee’ table are updated.
We can pass parameters to procedures in three ways.
1) IN-parameters 2) OUT-parameters 3) IN OUT-parameters A procedure may or may not return any value.
is a named PL/SQL block which performs one or more specific task.
A cursor contains information on a select statement and the rows of data accessed by it.
This indicates the oracle engine that the PL/SQL program has ended and it can begin processing the statements.
We have two parameter markers in our example (one as part of the SET clause expression and one in the WHERE clause), so we must list the host variables in the USING clause in the sequence the corresponding parameter markers appear in the SQL statement.
Secondly, the use of parameter markers greatly reduces the opportunity for any SQL injection threat to occur. INTO form doesn’t work in dynamic SQL, so you must use a cursor.
So that’s how we can dynamically handle direct “set at a time” updates and deletes. So imagine that in the example we just looked at, rather than updating all rows that met the WHERE clause selection criteria immediately, there was a bit more RPG logic that had to take place before the update happened (e.g., perhaps a user must manually enter the information about how much each employee’s salary change would be).