Home > Database > Oracle > How to use type in oracle

How to use type in oracle

WBOY
Release: 2022-06-13 15:27:53
Original
3816 people have browsed it

type in oracle: 1. Used to define the type of data, the syntax is "CREATE OR REPLACE TYPE ED_DYNAMIC_PROC_OBJ AS OBJECT (TYPE type)"; 2. Used to declare that the current element type is a known one Type, the syntax is "vempno emp.empno%type;".

How to use type in oracle

The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.

How to use type in oracle

There are two types of types in oracle, one is to define the type, and the other is to declare the type of the current element to be a known type

1. Define the type:

How to use type in oracle

2. Declare the type of the current element to be a known type

vempno emp.empno%type;

Declares a variable vempno, its type is the same as the type of the emp.empno attribute

Extended knowledge:

In addition, a VARRAY is used here

This is a collection in oracle,

CREATE OR REPLACE TYPE ED_DYNAMIC_PROC_LIST AS VARRAY(1000) OF ED_DYNAMIC_PROC_OBJ;

This sentence is equivalent to declaring a collection named ED_DYNAMIC_PROC_LIST with a size of 1000. This collection is used to store ED_DYNAMIC_PROC_OBJ objects.

The varray collection has an extend attribute:

EXTEND is in Adding an element to the end of the set is illegal for Index_by

EXTEND(x) Adding x elements to the end of the set is illegal for Index_by

EXTEND(x,n) Adding x copies of element n to the end of the set Illegal for Index_by

OUTARRAY.EXTEND;
OUTARRAY(V_COUNT):=V_DYNAMICOBJ;
V_COUNT:=V_COUNT+1;
Copy after login

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to use type in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template