InterviewSolution
| 1. |
What is a RAISE Statement in PL/SQL? |
|
Answer» ACTUAL parameters can be passed as Positional notation, Named notation as well as MIXED notation. In Positional Notation, the same parameters in the same order as they are declared in the procedure are specified. The actual parameter is associated with the formal parameter in named notation using the arrow symbol ( => ) like: x => aThe procedure call for this would be: myFunction(x => a, y => b, z => c);In PL/SQL, you can mix both notations in procedure call with n mixed notation. REMEMBER, the positional notation should precede the named notation. myFunction(x, y, z => c);The following is an example: Let’s say we have below given table: <DEPTBUDGET> +-----------+-----------------+---------------+------------------+ | DEPTID | DEPTNAME | DEPTLOC | BUDGET | +-----------+-----------------+---------------+------------------+ | 1 | Finance | NORTH | 56678 | | 2 | Marketing | EAST | 87687 | | 3 | Operations | WEST | 98979 | | 4 | Technical | SOUTH | 76878 | | 5 | Accounting | NORTHWEST| 86767 | +----------+------------------+------------------+--------------+Now, we will call with Positional, mixed and named notations: DECLARE d_id NUMBER(6) := 2; d_budget NUMBER(6) := 500; PROCEDURE new_budget (id NUMBER, amount_add NUMBER) IS BEGIN UPDATE employees SET budget = budget + amount_add WHERE deptid = id; END new_budget ; BEGIN new_budget (did, d_budget ); -- positional procedure call for actual parameters new_budget (amount_add => d_budget , id=> d_id); -- named parameters new_budget (d_id, amount_add => d_budget ); -- mixed parameters END;Above, you can see we have a procedure “new_budget”. We are updating the budget here: PROCEDURE new_budget (id NUMBER, amount_add NUMBER) IS BEGIN UPDATE employees SET budget = budget + amount_add WHERE deptid = id; END new_budget ;We are calling one by one with positional, mixed and named notation: new_budget (did, d_budget ); -- positional procedure call for actual parameters new_budget (amount_add => d_budget , id=> d_id); -- named parameters new_budget (d_id, amount_add => d_budget ); -- mixed parameters |
|