`
zhou_hong_liang
  • 浏览: 96200 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Record和PL/SQL表

SQL 
阅读更多
--将表zhl_table中的 记录都保存到red_array对象数组中,并输出
create or replace procedure zhl_3 is
  Type red is Record(
    rid   zhl_table.id%type,
    rname zhl_table.name%type);
  Type red_array is table of red index by binary_integer;
  myRed red_array;
  vn    number;
  vnn   number;
begin
  vn := 1;
  for vr in (select * from zhl_table) loop
    myRed(vn).rid := vr.id;
    myRed(vn).rname := vr.name;
    vn := vn + 1;
    --dbms_output.put_line(vr.id);
  end loop;
  --vnn := myRed.First;
  for I in 1 .. myRed.count loop
    dbms_output.put_line(myRed(I).rid || ' ' || myRed(I)
                         .rname);
    --vnn := myRed.next(vnn);
  end loop;
end;

--将表整体赋值给对象数组red_array
create or replace procedure zhl_3 is
  Type red is Record(
    rid   zhl_table.id%type,
    rname zhl_table.name%type);
  Type red_array is table of red index by binary_integer;
  myRed red_array;
  vn    number;
  vnn   number;
begin
  vn := 1;
  for vr in (select * from zhl_table) loop
    myRed(vn) := vr;
    vn := vn + 1;
  end loop;
  for I in 1 .. myRed.count loop
    dbms_output.put_line(myRed(I).rid || ' ' || myRed(I)
                         .rname);
  end loop;
end;

--利用表的索引键id给red_array赋值
create or replace procedure zhl_3 is
  Type red is Record(
    rid   zhl_table.id%type,
    rname zhl_table.name%type);
  Type red_array is table of red index by binary_integer;
  myRed red_array;
  vn    number;
  vnn   number;
begin
  for vr in (select * from zhl_table) loop
    myRed(vr.id) := vr;
  end loop;
  for I in 1 .. myRed.count loop
    dbms_output.put_line(myRed(I).rid || ' ' || myRed(I)
                         .rname);
  end loop;
end;


  --使用主键约束和唯一约束作为索引列和使用%ROWTYPE类型作为可用列
  create or replace procedure zhl_3 is
  Type red is table of zhl_table%rowtype index by binary_integer;
  myRed red;
  vn    zhl_table.id%type;
begin
  for vr in (select * from zhl_table) loop
    myRed(vr.id) := vr;
  end loop;
  for I in 1 .. myRed.count loop
    dbms_output.put_line(myRed(I).id || ' ' || myRed(I).name);
  end loop;
end;
分享到:
评论

相关推荐

    PL/SQL Developer 6.05注册版-1

    <br>此版本包含注册文件和简体中文语言安装包 <br>Enhancements in PL/SQL Developer 7.1.5 ====================================== - Fixed some access violations - Inserting a record in the ...

    PL/SQL Developer 7.1.5 注册版-3

    <br>此版本包含注册文件和简体中文语言安装包 <br>Enhancements in PL/SQL Developer 7.1.5 ====================================== - Fixed some access violations - Inserting a record in the ...

    PL/SQL Developer8.04官网程序_keygen_汉化

    FETCH cursor_name INTO PL/SQL_record;  4)关闭游标。CLOSE cursor_name 注意:在声明游标时,select_statement不能包含INTO子句。当使用显示游标时,INTO子句是FETCH语句的一部分。  2 隐式游标 所有的隐式...

    PL/SQL Developer 7.1.5 注册版

    <br>此版本包含注册文件和简体中文语言安装包 <br>Enhancements in PL/SQL Developer 7.1.5 ====================================== - Fixed some access violations - Inserting a record in the ...

    PL/SQL 基础.doc

    单纯的计算---->BINARY_INTEGER 考虑和表中其他数据的交互的话一般------->NUMBER 字符型、CHAR VARCHAR VARCHAR2 STRING LONG 一般CHAR VARCHAR2就够了 CHAR 定长(例子:CHAR(5) 如果不够5个字符的话就会用空白...

    plsqldev12.0.4.1826x64主程序+ v12中文包+keygen

    The new PL/SQL Clipboard is a dockable tool that stores the history of all SQL and PL/SQL code you copy to the Windows clipboard, so that you can paste the clipboard item again in the future....

    PLSQLDeveloper下载

    Create or replace procedure procname(参数列表) as PL/SQL语句块 函数:Create or replace function funcname(参数列表) return 返回值 as PL/SQL语句块 为便于理解,举例如下: 问题:假设有一张表t1,有f1和f2两...

    ORACLE SQL PLSQL

    1. 用pl/sql的存储过程和数据库触发器实现至关重要的商业规则。 2. 在数据库中生成和完全地管理xml文档。 3. web页面与数据库的结合。 4. 实现自动化的数据库管理,用pl/sql建立安全级别来管理回滚段。 1-2 pl/sql...

    plsqldev14.0.0.1961x32多语言版+sn.rar

    For these file control operations PL/SQL Developer relies on a 3rd party shell extension that must be installed on your system. In the screenshots above “GIT Extensions” has been used. Worksets A ...

    PL sql 培训教程

    了解PL/SQL最好的方法就是从简单的实例入手。下面的程序是用于处理一个网球拍订单的。首先声明一个NUMBER类型的变量来存放现有的球拍数量。然后从数据表inventory中把球拍的数量检索出来。如果数量大于零,程序就会...

    Oracle P/L SQL实现FTP上传、下载功能

    Oracle P/L SQL实现FTP上传、下载功能,以下是此过程包的头部,包体经常打包处理plb,感兴趣用户可以下载下来。 --Oracle上的FTP功能 Create or Replace Package UTL_FTP AUTHID CURRENT_USER as Type Connection ...

    PLSQL.Developer(X32) v12.0.1.1814主程序+ v11中文包+keygen

    The new PL/SQL Clipboard is a dockable tool that stores the history of all SQL and PL/SQL code you copy to the Windows clipboard, so that you can paste the clipboard item again in the future....

    plsqldev12.0.4.1826x32主程序+ v12中文包+keygen

    The new PL/SQL Clipboard is a dockable tool that stores the history of all SQL and PL/SQL code you copy to the Windows clipboard, so that you can paste the clipboard item again in the future....

    PLSQL.Developer(X64) v12.0.1.1814 主程序+ v11中文包+keygen

    The new PL/SQL Clipboard is a dockable tool that stores the history of all SQL and PL/SQL code you copy to the Windows clipboard, so that you can paste the clipboard item again in the future....

    SQL&PL SQL FAQ第二版

    一、SQL&PL SQL 1.怎么样大批量的更新数据而不影响正常业务 2.怎么对IN子查询使用绑定变量 3.并发容易出现的问题与并发控制 4.怎么使用object与record类型返回表类型数据 5.怎么样在业务繁忙时期正确的创建表约束...

    plsqldev13.0.3.1902x32主程序+ v12中文包+keygen

    32位版本的 PLSQL 正式版。 安装中文包时请注意安装路径是否为PLSQL程序的路径。 安装请查看说明。...An error message about "GetTickCount64" could appear when starting PL/SQL Developer on Windows XP

    Oracle8i_9i数据库基础

    §12.4.2 复合类型(记录和表) 238 §12.4.3 使用%ROWTYPE 240 §12.4.4 LOB类型 240 §12.4.5 用户定义的子类型 241 §12.4.6 数据类型的转换 243 §12.5 运算符和表达式(数据定义) 243 §12.5.1 关系运算符 243 ...

    plsqldev13.0.3.1902x64主程序+ v12中文包+keygen

    64位版本的 PLSQL 正式版,只能运行在64位系统中,需要你安装 64 位的 Oracle11g 或 Oracle12c 客户端。...An error message about "GetTickCount64" could appear when starting PL/SQL Developer on Windows XP

    PLSQL Developer 11 中文绿色版

    PL/SQL Developer 11.0 - New Features Below you can find a brief description of the most important new features in PL/SQL Developer 11.0. New features SQL Window enhancements The result set toolbar ...

Global site tag (gtag.js) - Google Analytics