Basic Oracle Concepts and Programming Question:
Download Job Interview Questions and Answers PDF
How To Assign a Table Row to a RECORD Variable?
Answer:
If you have a table, and want to assign a data row of that table to a RECORD variable, you need to define this RECORD variable to match the table column structure, then use the SELECT ... INTO statement to assign a data row that RECORD variable. The script below shows you how to do this:
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
manager employees%ROWTYPE;
BEGIN
SELECT * INTO manager FROM employees
WHERE employee_id = 100;
DBMS_OUTPUT.PUT_LINE('My manager = ' ||
manager.first_name || ' ' || manager.last_name);
END;
/
My manager = Steven King
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
manager employees%ROWTYPE;
BEGIN
SELECT * INTO manager FROM employees
WHERE employee_id = 100;
DBMS_OUTPUT.PUT_LINE('My manager = ' ||
manager.first_name || ' ' || manager.last_name);
END;
/
My manager = Steven King
Download Oracle Database Interview Questions And Answers
PDF
Previous Question | Next Question |
How To Define a RECORD Variable to Store a Table Row? | How To Insert a Record into a Table? |