PL-SQL复合数据类型.ppt

  1. 1、本文档共64页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第5章 PL/SQL(复合数据类型)    1 记录    2 集合    3 BULK COLLECT    4 FORALL STATEMENT    5 ROWNUM    6 ROWID and UROWID     1 记录 记录类型显式定义的一般格式: TYPE <recordtypename> IS RECORD ( <field> <datatype> [[NOT NULL]{DEFAULT|:=} <expression>] [,<field> …] ); [说明] 标识符 <recordtypename>是定义的记录类型名; 要定义记录型变量,定义方法与前面标量型变量定义一样。 记录类型变量的属性引用方法是‘.’引用。 example %ROWTYPE Assigning Values to Records Assigning Values to Records Assigning Values to Records As Procedure Parameter Returning a Record Inserting PL/SQL Records into the Database Updating the Database with PL/SQL Record Values 2 PL/SQL 集合 a、Index_by表; b、嵌套表; c、VARRAY Choosing Which Collection Types to Use? Array versus Nested Table Defining Collection Types To create collections, you define a collection type, then declare variables of that type.—先定义类型,再定义变量。 Collections follow the same scoping and instantiation rules as other types and variables.—遵从与其他类型和变量一样的范围和实例化规则。 Index_by表 语法如下: TYPE type_name IS TABLE OF element_type [NOT NULL] INDEX BY BINARY_INTEGER; 关键字是INDEX BY BINARY_INTEGER。由于不存储在数据库中,element_type可以是任何合法的PL/SQL数据类型,包括:PLS/INTEGER、SIGNTYPE、和BOOLEAN。 VARRAY 语法 TYPE type_name IS [VARRAY|VARYING ARRAY] (max_size) OF element_type [NOT NULL]; max_size是一个整数,用于标示VARRAY集合拥有的最多元素数目。VARRAY集合的元素数量可以低于max_size,但不能超过max_size。 嵌套表 语法 TYPE type_name IS TABLE OF element_type [NOT NULL]; 嵌套表非常类似于Index_by表,创建的语法也非常相似。只是没有INDEX BY BINARY_INTEGER子串。 Declaring Collection Variables Initializing and Referencing Collections To initialize a nested table or varray, you use a constructor, a system-defined function with the same name as the collection type. Associative arrays do not use constructors. Constructor for a Nested Table Constructor for a Varray Empty Varray Constructor Referencing Collection Elements collection_name(subscript) example example Assigning Collections 为集合元素赋值的语法 collection_name(subscript) := expression; Cause exceptions 赋值兼容 集合操作符(10g) multiset except multiset except distinct multiset intersect multiset intersect distinct mul

文档评论(0)

yurixiang1314 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档