`

Oracle FORALL_Example_2

阅读更多
-- Created on 2010/05/07 by NAN
declare
  -- Local variables here
  TYPE numtab IS TABLE OF NUMBER(20 ) INDEX BY BINARY_INTEGER ;

    TYPE nametab IS TABLE OF VARCHAR2 (50) INDEX BY BINARY_INTEGER;
    pnums  numtab;
    pnames nametab;
    t1     NUMBER;
    t2     NUMBER;
    t3     NUMBER;
    ERRORS NUMBER;
begin
 FOR j IN 1 .. 1000
    LOOP
        pnums(j) := j;
        pnames(j) := 'Seq No. ' || to_char(j);
    END LOOP ;

    SELECT dbms_utility.get_time
    INTO   t1
    FROM   dual;

    FOR i IN 1 .. 1000
    LOOP
        INSERT INTO blktest
        VALUES
            (pnums(i)
            ,pnames(i));
    END LOOP ;

    SELECT dbms_utility.get_time
    INTO   t2
    FROM   dual;
    pnums.delete( 10);
    pnums.delete( 15);
    FORALL i IN 1 .. 1000 SAVE EXCEPTIONS
        INSERT INTO blktest
        VALUES
            (pnums(i)
            ,pnames(i));
       
    SELECT dbms_utility.get_time
    INTO   t3
    FROM   dual;
    dbms_output.put_line( 'Execution Time (hsecs)');
    dbms_output.put_line( '---------------------');
    dbms_output.put_line( 'FOR loop: ' || to_char(t2 - t1));
    dbms_output.put_line( 'FORALL:   ' || to_char(t3 - t2));
    COMMIT;
EXCEPTION
    WHEN OTHERS THEN
         ERRORS     := SQL%BULK_EXCEPTIONS.COUNT;
         FOR i IN 1 .. SQL%BULK_EXCEPTIONS.count LOOP
             dbms_output.put_line( SQL%BULK_EXCEPTIONS (i).ERROR_INDEX);
             dbms_output.put_line( SQL%BULK_EXCEPTIONS (i).ERROR_CODE);
         END LOOP ;
         dbms_output.put_line( SQLERRM);
         COMMIT;
end;

分享到:
评论

相关推荐

    Linux__Oracle_12c_RAC安装配置v1.0.docx

    - 支持Oracle Linux 6和Red Hat Enterprise Linux 6 Distributions for x86-64 - 支持Oracle Linux 5和Red Hat Enterprise Linux 5 Distributions for x86-64 - 支持SUSE Distributions for x86-64 ##### 2.3 ...

    最全的oracle常用命令大全.txt

    ORACLE常用命令 一、ORACLE的启动和关闭 1、在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a、启动ORACLE系统 oracle>svrmgrl SVRMGR>connect internal SVRMGR>startup ...

    DB2_Install_ for_linux

    2. 检查备份:`db2 list backup history all` 3. 恢复数据库:`db2 restore database mydb from '/backup'` 七、监控与性能调优 1. 查看数据库状态:`db2pd -db mydb` 2. 监控数据库性能:`db2top` 3. 调整DB2配置...

    怎么在oracle10g查询所有包含某字段的表名.doc

    Oracle 10g数据库系统是Oracle公司发布的一个版本,提供了丰富的功能和强大的性能。在数据库管理中,有时候我们需要查找所有包含特定字段的表,这对于数据治理、数据分析或优化查询性能非常有帮助。以下是如何在...

    plsql excel example

    5. **BULK COLLECT和FORALL**:为了提高效率,当从数据库大量导出数据时,可以使用PL/SQL的BULK COLLECT语句收集数据,然后使用FORALL语句批量插入到Excel文件。 6. **外部表**:Oracle的外部表功能允许将文件系统...

    【OracleRAC】LinuxOracle11gR2RAC安装配置详细过程V3.0(图文并茂)

    - `linux_11gR2_database_1of2` - `linux_11gR2_database_2of2` - `linux_11gR2_grid` 以上文件均可从 Oracle 官方网站下载: - [下载地址]...

    Oracle Core Essential Internals

    unreadable Consider for example the simple question: How does Oracle do a logical I O then take a look at structure x$kcbsw which is a list of all the functions that Oracle might call to visit a ...

    Oracle+10G+-+Plsql+User's+Guide

    The FORALL statement can handle associate arrays and nested tables with deleted elements. You can now use this performance construct in more situations than before, and avoid the need to copy elements...

    oracle asm rac

    Changing password for user oracle. New UNIX password: BAD PASSWORD: it is based on a dictionary word Retype new UNIX password: passwd: all authentication tokens updated successfully. 创建grid目录结构...

    oracle从基础到精通

    - Toad for Oracle - PL/SQL Developer - SQL Server Management Studio (适用于跨平台) - **SQL在编程中的应用:** - SQL通常与各种编程语言结合使用,例如Java、Python、C#等。 - 数据持久层技术如JDBC、ADO...

    Oracle提高与精通

    That is the Oracle code !! You can use it improve your ability!! You know if you don't use the DATABASE and The Commnad that you...All example in the RAR File!! Hope you can use it and it can help you!!!

    RACGuides_Rac10gR2OnLinux.pdf

    - **Example of Configuring Block Device Storage for Oracle Clusterware**:配置块设备存储的具体示例。 - **Example of Creating...** 通过上述详细的内容,我们可以看出文档提供了从软件要求、硬件配置、...

    Oracle sqldeveloper without jdk (win+linux)

    - The script to which the character belongs is supported by the JRE installation on which SQL Developer is running � for example, appropriate fonts are available � and - The script does not ...

    core_servlets_and_javaserver_pages_advanced_technologies_volume_2_2nd_edition

    Suppose your company wants to sell products online. You have a database that gives the price and inventory status of each item. However, your database doesn’t speak ...Web browsers need.... For example,

    php.ini-development

    2. The PHPRC environment variable. (As of PHP 5.2.0) ; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) ; 4. Current working directory (except CLI) ; 5. The web server's directory...

    11g_plsql_user_guide_and_reference.pdf

    For example, they can specify whether a trigger should be executed before or after a DML operation, or whether it should be executed for each row or for the entire statement. This level of control ...

    advanced oracle pl-sql

    Chapter 5, PL/Vision Package Specifications provides a brief summary of all of the specifications for the PL/Vision packages, and is marked with a thumb-tab for quick reference. Part III: Building ...

    MySQL and JSON A Practical Programming Guide 2018

    Written by a MySQL Community Manager for Oracle, MySQL and JSON: A Practical Programming Guide shows how to quickly get started using JSON with MySQL and clearly explains the latest tools and ...

    学习使用SQLAlchemy框架,在ORM模式下实现Python与MySQL的连接、结构设计和增删查改.zip

    users = session.query(User).all() for user in users: print(user.name, user.email) # 更新数据 john = session.query(User).filter_by(name='John').first() john.email = 'newemail@example.com' session....

    SQL Assistant v5.0

    Preset code formatting rule added for Oracle VARRAY. Preset code formatting rule added for DEFAULT VALUES in INSERT/UPDATE statements in Transact-SQL. Database name and schema name completion is now...

Global site tag (gtag.js) - Google Analytics