This section provides an overview of what plsql is, and why a developer might want to use it.
It should also mention any large subjects within plsql, and link out to the related topics. Since the Documentation for plsql is new, you may need to create initial versions of those related topics.
Declared Cursors are difficult to use, and you should prefer FOR
loops in most cases. What's very interesting in cursors compared to simple FOR
loops, is that you can parameterize them.
It's better to avoid doing loops with PL/SQL and cursors instead of using Oracle SQL anyway. However, For people accustomed to procedural language, it can be far easier to understand.
If you want to check if a record exists, and then do different things depending on whether the record exists or not, then it makes sense to use MERGE
statements in pure ORACLE SQL queries instead of using cursor loops.
(Please note that MERGE
is only available in Oracle releases >= 9i).
It is important to note that an object body may not always be necessary. If the default constructor is sufficient, and no other functionality needs to be implemented then it should not be created.
A default constructor is the Oracle supplied constructor, which consists of all attributes listed in order of declaration. For example, an instance of BASE_TYPE could be constructed by the following call, even though we do not explicitly declare it.
l_obj := BASE_TYPE(1, 'Default', 1);