Functions (Cont.)
In PL/SQL, parameters are not copies but the actual argument variables used in the function call, and the compiler rejects code that tries to modify them.
1 | SQL > CREATE FUNCTION increase( x INT ) RETURN INT IS |
8 | Warning: Function created with compilation errors. |
|
It would not be possible to use
increase(x in out int)
in arbitrary SQL statement, because SQL expressions are not supposed to change data.
Since parameter variables must be read-only, we need to declare local variables to hold immediate and final results.
01 | SQL > CREATE TYPE name_type AS OBJECT ( |
07 | SQL > CREATE TYPE person_type AS OBJECT ( |
13 | SQL > CREATE TABLE people_tab OF person_type; |
16 | SQL > INSERT INTO people_tab VALUES ( |
17 | 2 person_type( 123456789, name_type( 'Door' , 'Kids' , 'N' ), 36 ) ); |
|