Index | Home | Forums
Oracle PL/SQL Example 2-6 Using %TYPE With the Datatype of a Variable

Example 2-6 Using %TYPE With the Datatype of a Variable

DECLARE
  credit PLS_INTEGER RANGE 1000..25000;
  debit  credit%TYPE;
  v_name VARCHAR2(20);
  name VARCHAR2(20) NOT NULL := 'JoHn SmItH';
-- If we increase the length of NAME, the other variables become longer also
  upper_name name%TYPE := UPPER(name);
  lower_name name%TYPE := LOWER(name);
  init_name name%TYPE := INITCAP(name);
BEGIN
-- display inherited default values
  DBMS_OUTPUT.PUT_LINE('name: ' || name || ' upper_name: ' || upper_name 
          || ' lower_name: ' || lower_name || ' init_name: ' || init_name);
-- lower_name := 'jonathan henry smithson'; invalid, character string is too long
-- lower_name := NULL; invalid, NOT NULL CONSTRAINT
-- debit := 50000; invalid, value out of range
END;
/


This page was created by oracleabc.com on Feb 23,2008 00:09:02
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here