Declare Variables, Constants and Types in Oracle PL/SQL
3312 단어 variable
<name> [CONSTANT] <datatype> [NOT NULL] [:= | DEFAULT <expr>]
Examples:
DECLARE
--Define some scalar variables
v_year NUMBER(4);
v_pin VARCHAR2(12);
v_min_amount NUMBER(20, 2) := 25000;
--Define a record type
TYPE t_customer IS RECORD (
id NUMBER(18),
first_name VARCHAR2(32),
last_name VARCHAR2(32),
);
--Declare a record variable
v_customer t_customer;
--Declare a composite type to hold a list of records
TYPE t_customer_list IS TABLE OF t_customer;
--Declare a record variable refering an existing table
v_employee employee%ROWTYPE;
BEGIN
v_year := 2010;
-- More PL/SQL code here.
END;
Declare RECORD variables and types
A specific RECORD TYPE corresponding to a fixed number (and datatype) of underlying table columns can simplify the job of defining variables.
%TYPE is used to declare a field with the same type as that of a specified table’s column.%ROWTYPE is used to declare a record with the same types as found in the specified database table, view or cursor.
Declare RECORD type
TYPE <type_name> IS RECORD(
<field_declaration>,...);
Each record field is declared with its ‘field_declaration’:
<field_name> {<field_type> |
<variable>%TYPE |
<table.column>%TYPE |
<table>%ROWTYPE}
[ [NOT NULL] {:= | DEFAULT} <expr> ]
The
To declare a record variable:
<variable_identifier> <type_name>;
You can declare a variable based on a record reference using %ROWTYPE:
<variable_name> <table_or_curosr_name>%ROWTYPE
The number of variables and their data type is evaluated at run-time.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
script - variable(변수)자바스크립트는 웹사이트 검사 중 console 칸에서 나타나진다. 자바스크립트는 숫자와 문자를 알아듣는다. 자바스크립트는 위에서부터 읽는다. ex) 2 ''도 된다. ex) "hi" or 'hi' or "2" 먼저 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.