How To Define a RECORD Variable to Store a Table Row?
Submitted by: AdministratorIf you have a table, and want to define a RECORD variable to store all the data elements of a row from that table, you can use table_name%ROWTYPE to define the RECORD variable as shown in the following sample script:
CREATE TABLE student (id NUMBER(5) PRIMARY KEY,
first_name VARCHAR(80) NOT NULL,
last_name VARCHAR(80) NOT NULL);
Table created.
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
best_student student%ROWTYPE;
another_student student%ROWTYPE;
class_name VARCHAR2(80);
BEGIN
class_name := 'ggl Center 2006';
best_student.first_name := 'The';
best_student.last_name := 'Best';
DBMS_OUTPUT.PUT_LINE('Best student ID = '
|| best_student.id);
DBMS_OUTPUT.PUT_LINE('Best student = ' ||
best_student.first_name || ' '
|| best_student.last_name);
END;
/
Best student ID =
Best student = The Best
Submitted by: Administrator
CREATE TABLE student (id NUMBER(5) PRIMARY KEY,
first_name VARCHAR(80) NOT NULL,
last_name VARCHAR(80) NOT NULL);
Table created.
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
best_student student%ROWTYPE;
another_student student%ROWTYPE;
class_name VARCHAR2(80);
BEGIN
class_name := 'ggl Center 2006';
best_student.first_name := 'The';
best_student.last_name := 'Best';
DBMS_OUTPUT.PUT_LINE('Best student ID = '
|| best_student.id);
DBMS_OUTPUT.PUT_LINE('Best student = ' ||
best_student.first_name || ' '
|| best_student.last_name);
END;
/
Best student ID =
Best student = The Best
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Call a Stored Function in Oracle? |
☺ | How Run SQL*Plus Commands That Are Stored in a Local File? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | What Happens to Indexes If You Drop a Table? |
☺ | What Is an Oracle User Account? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |