We created OBJECT TYPE in the previous section. Now let us see how we can access the information of OBJECT TYPE using PL/SQL. Let us consider the following example. declare From the above program, ‘v_experience’ is declared based on the OBJECT TYPE ‘t_experience’. The most important statement to understand from the above program is the following: select value(e) into v_experience The table ‘employees’ is aliased as ‘e’ and we are using ‘value’ (in combination with alias) function to return values in the form of an OBJECT (instead of values). The OBJECT returned by VALUE is placed into ‘v_experience’ variable and I hope the rest is same. Another important issue to remember is that, it is not compulsory to return VALUE in the form of object. We can also use individual variables as the following: declare The above can also be rewritten using TYPE with RECORD to retrieve OBJECT based TABLE information as following: declare Till now, all the above programs are working with only single rows of OBJECTs. What about more number of rows? We can follow the same approach explained in Part-2 or Part-3 of this series and modify a bit as following: declare We must understand that there exists several number of ways to retrieve the OBJECT based TABLE information. We need to follow certain methods appropriate to the situation rather than confusing ourselves with all of them.
blog comments powered by Disqus |