In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about how to understand pl/sql record. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.
PL/SQL records (record) are equivalent to structures in high-level languages and are useful for processing single lines of data. For example, when you want to retrieve an employee's name, salary, and benefits, if you use scalar variables to receive data, you need to define three variables. To simplify the processing of single-row, multi-column data, you can use records.
1. Define Record
When defining, it can be the developer and custom record types and record variables, or you can use% rowtype to define record variables directly.
For example: custom Record
DECLARE
TYPE emp_record_type IS RECORD (
Name emp.ename%type
Salary emp.sal%type
Dno emp.deptno%type
);
Emp_record emp_record_type
Emp_record is a record variable defined based on the record type emp_record_type. Record variable name: emp_record
2. Use the% rowtype attribute to define record variables
% rowtype can define record variables based on tables or views. When you use this property to define a record variable, the name and type of the record member are exactly the same as the column name and type of the table or view.
Syntax: identifier table_name%rowtype
When a record variable is defined using the% rowtype attribute, the number, name, and type of record members are the same as the number, name, and type of columns in the table or view.
For example:
Emp_record emp%rowtype
The member name of the record variable emp_record is the column name of the table emp (empno, ename..)
Examples of use:
Set serveroutput on
DECLARE
TYPE emp_record IS RECORD (
Name emp.ename%type
Salary emp.sal%type
Dno emp.deptno%type
);
Emp_record emp_record_type
BEGIN
Select ename,sal,deptno INTO emp_record
FROM emp
WHERE empno=&no
Dbms_output.put_line (emp_record.name)
END
When referencing a record variable member, you must prefix the member name with the record variable name.
After reading the above, do you have any further understanding of how to understand pl/sql record? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.