What is the %TYPE attribute?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the %TYPE attribute?

Rating:

When a PL/SQL variable is declared to hold column values, it must be ensured that the variable is of the correct datatype and precision. If not, a PL/SQL error occurs during execution. Rather than explicitly specifying the datatype and precision of a variable, the %TYPE attribute can be used to declare a variable according to another previously declared variable or database column.

The %TYPE attribute is generally used when the value stored in the variable will be derived from a table in the database. In order to use the %TYPE attribute in place of the datatype that is required in the variable declaration, the attribute is prefixed with the table name and column name. If referring to a previously declared variable, the attribute is prefixed with the name of the variable.

When a PL/SQL block consisting of such variables is compiled, the PL/SQL determines the datatype and size of the variables in order to ensure that such variables are always compatible with the column that is used to populate it. This is a definite advantage for writing and maintaining code because there is no need to be concerned about column datatype changes made at the database level.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.