How To Define a Variable to Match a Table Column Data Type?
Submitted by: AdministratorIf 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 ggl_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);
END;
/
My email = NKOCHHAR
My salary = 17000
Submitted by: Administrator
CREATE OR REPLACE PROCEDURE ggl_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);
END;
/
My email = NKOCHHAR
My salary = 17000
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Use "OUT" Parameter Properly? |
☺ | How Run SQL*Plus Commands That Are Stored in a Local File? |
☺ | How To Create a Stored Procedure in Oracle? |
☺ | What Is the Relation of a User Account and a Schema? |
☺ | What Happens to Indexes If You Drop a Table? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |