I’m new in PLSQL (about a week) and I have an object with hundreds attributes and I need to check which ones are filled and null to add to a clob.
It is possible to iterate in the object attributes like
for i in object loop
object.i
end loop;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using standard PL/SQL construct you cannot. You can iterate through a collection using
Variable i is not index but one element of the iterated collection.
If your object is an Oracle TYPE you can query a system view ALL_TYPE_ATTRS. This view is part of a database catalog. You find its description in Oracle Reference (not Oracle SQL Reference!). You get a list of attribute names, I’m not sure, if you can access it in dynamic way.
The simplest way is to write a set of helper procedures which will check an attribute according its type and manage its value and then simply call this procedure.