zoukankan      html  css  js  c++  java
  • oracle pl/sql中record和%rowtype整理

    1. 创建stu表,如下:

      create table stu(s1 number, s2 number);

    2. 定义多维数组, 能用来接受多条返回数据

      方式一:   type type_name is table of stu%rowtype;           # 基于表中行类型的多维数组

          custom_type type_name;                                    # 定义该多维数组变量

          execute immediate 'select * from stu where s1>:1' bulk collect into custom_type using in 5;

      方式二:   type list_name is record(x number, y number);   # 先定义record, record即一维数组, 

          type type_name is table of list_name;                  # 使用定义的一维数组定义多维数组

          custom_type type_name;               # 定义该多维数组变量

          execute immediate 'select * from stu where s1>:1' bulk collect into custom_type using in 5;

    3. 定义一维数组, 用来接受一条返回数据

      方式一:   type list_name is record(x number, y number);    # 先定义record, record即一维数组.

          custom_type list_name                  #定义该一维数组变量.

          execute immediate 'select * from stu where s1=:xx' into custom_type using in 1;

      方式二:   custom_type stu%rowtype;                           # 使用表的行类型定义一维数组变量

          execute immediate 'select * from stu where s1=:xx' into custom_type using in 1;

    4. 以上是演示多行多列和单行多列的返回值接受, 单列多行和单列单行的返回值接受和上面类似, 定义时

        使用table.column%type 或 record(x number)定义行一维的单元素数组后, 再使用同上的定义多维度的

        办法, 即可用来接受单列多维数据或单列单维数据.

  • 相关阅读:
    Python学习笔记4—列表List
    Python学习笔记3—字符串
    电力项目十六--数据字典二
    电力项目十五--数据字典
    maven项目引入jar包
    电力项目十四--js添加highslider特效
    电力项目十三--js添加浮动框
    电力项目十二--运行监控中添加进度条
    panzer 电力项目十一--hibernate操作大文本字段Blob和Clob
    电力项目十--整合文本编辑器
  • 原文地址:https://www.cnblogs.com/quzq/p/12068327.html
Copyright © 2011-2022 走看看