1.

How To Define A Variable To Match A Table Column Data Type?

Answer»

If you have a table, and want to define some variables to have exactly the same DATA types as some columns in that table, you can use table_name.column_name%TYPE as data types to define those variables. The TUTORIAL sample below SHOWS you how to do this:

CREATE OR REPLACE PROCEDURE FYI_CENTER AS my_email employees.email%TYPE; my_salary employees.salary%TYPE; BEGIN SELECT email, salary INTO my_email, my_salary FROM employees WHERE employee_id = 101; DBMS_OUTPUT.PUT_LINE('My email = ' || my_email); DBMS_OUTPUT.PUT_LINE('My salary = ' || my_salary); 73 END; / My email = NKOCHHAR My salary = 17000

If you have a table, and want to define some variables to have exactly the same data types as some columns in that table, you can use table_name.column_name%TYPE as data types to define those variables. The tutorial sample below shows you how to do this:



Discussion

No Comment Found