`
从百草园到三味书屋
  • 浏览: 52532 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

oracle学习--存储过程.sql

 
阅读更多
create or replace procedure test
as 
begin
  dbms_output.put_line('hello world!');
end;
show serveroutput;
set serveroutput on;

begin
  test;
end;

select * from user_source where name='TEST' order by line;
select * from user_source where name='TEST2' order by line;
create or replace procedure product_update_prc 
as
begin
  update productinfo set description='促销产品'
  where productid in (
    select productid from (select * from productinfo order by productprice asc) where rownum<4
  );
  commit;
end;
/
declare
  cursor mycursor is select * from productinfo;
  myrow productinfo%rowtype;
begin
  product_update_prc;
  /*
  for r in mycursor loop
    dbms_output.put_line(r.description);
  end loop;*/
  open mycursor;
    loop
      fetch mycursor into myrow;
      exit when mycursor%notfound;
      dbms_output.put_line(myrow.description);
    end loop;
  close mycursor;
end;
show errors procedure product_update_prc;


create or replace procedure test2 
as 
  v_categoryid categoryinfo.categoryid%type;
  v_categoryname categoryinfo.categoryname%type;
  
  cursor cursor_categoryid is select category from productinfo group by category;
  
begin
  open cursor_categoryid;
  loop
    fetch cursor_categoryid into v_categoryid;
    exit when cursor_categoryid%notfound;
    select categoryname into v_categoryname from categoryinfo where categoryid=v_categoryid;
    dbms_output.put_line(v_categoryname);
    
    for product in (
      select * from productinfo where category=v_categoryid
    )
      loop
        dbms_output.put_line(product.productid||' '||product.productname||' '||product.productprice);
      end loop;
    end loop;
    close cursor_categoryid;
end;
show errors procedure test2;

begin
  test2;
end;
分享到:
评论

相关推荐

    oracle-xe-11.2.0-1.0.x86_64.rpm.zip

    Oracle XE 11.2.0 是一款...Oracle XE 11.2.0 是一个强大且易于入门的数据库解决方案,尤其适合学习 Oracle 数据库基础、开发小型项目或进行测试环境搭建。通过理解其特性、安装流程以及日常管理,可以充分发挥其价值。

    oracle-instantclient-12.2.0.1.0-1.x86_64的rpm格式

    一旦安装完成并配置好,Oracle Instant Client可用于开发和测试数据库连接,如创建数据库连接池、执行SQL查询、调用存储过程等。它也常用于数据库备份、性能监控和故障排查工具,因为它不需要完整的数据库服务器...

    oracle instantclient-odbc-win32-10.2.0.5.zip

    Oracle Instant Client是Oracle公司...总的来说,"oracle instantclient-odbc-win32-10.2.0.5.zip"提供了在Windows 32位系统下通过ODBC连接Oracle数据库的功能,简化了开发和部署过程,同时也降低了系统资源的需求。

    sqlplus 11.2 安装包oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

    通过SQL*Plus,你可以执行脚本、创建报告、进行数据操作以及管理数据库对象,如表、视图、存储过程等。它提供了丰富的交互式环境和高级特性,如格式化输出、条件处理、批处理等。 2. **Oracle Instant Client**:这...

    instantclient-basic-win32-11.1.0.6.0.zip

    请注意,虽然Instant Client提供了基础的数据库连接功能,但一些高级特性,如数据泵(expdp/impdp)、存储过程调试等,可能需要安装更完整的数据库客户端或服务器。此外,为了保证安全性,及时更新到最新版本的...

    Oracle官方32位客户端-instantclient-basic-nt-12.2.0.1.0

    Oracle官方的32位客户端Instant Client是数据库管理员和开发人员常用的一款工具,它允许用户在不安装完整Oracle数据库服务器的情况下,进行数据查询、应用程序开发和调试。本文将深入解析"Oracle官方32位客户端-...

    PLsql绿色下载+Oracle安装包instantclient-basic-win32-11.2.0.1.0

    它提供了全面的环境,支持创建、编辑、运行和调试PL/SQL代码,包括存储过程、函数、触发器等。此外,它还具备查询和报表生成功能,可以进行数据导入导出,数据库对象的管理,以及图表视图的创建,极大提升了开发效率...

    Oracle PL-SQL语言初级教程.pdf

    PL/SQL是Oracle专为数据库应用设计的编程语言,它允许开发者编写存储过程、函数、触发器等,以实现复杂的业务逻辑。PL/SQL与SQL不同,SQL主要用于查询和数据操作,而PL/SQL则增加了流程控制、异常处理、变量定义等...

    instantclient-basic-nt-11.2.0.4.0与instantclient-odbc-nt-11.2.0.4.0.rar

    这些文件允许开发人员和最终用户在本地或远程机器上执行SQL查询、调用存储过程、以及进行其他与Oracle数据库交互的操作。此版本还支持oci连接方式,是大多数Oracle数据库应用程序的基础。 1. oci.dll:Oracle Call ...

    cx_Oracle-5.2.1-11g.win-amd64-py3.5

    9. **游标方法**:如`callproc()`用于调用存储过程,`fetchone()`、`fetchmany()`、`fetchall()`用于获取查询结果。 10. **高级特性**:如LOB(大型对象)操作、PL/SQL块执行、绑定变量、异步操作等。 在使用cx_...

    instantclient-sqlplus-windows.x64-19.5.0.0.0dbru.zip

    Oracle的Instant Client SQL*Plus是Oracle数据库用户的重要工具,它为Windows 64位系统提供了高效的数据管理和查询功能。这个名为"Instantclient-sqlplus-windows.x64-19.5.0.0.0dbru.zip"的压缩包包含了版本19.5的...

    instantclient-odbc-nt-12.1.0.1.0.zip 官网原版

    在开发环境中,Oracle Instant Client ODBC驱动尤其有用,因为它可以减少对完整Oracle客户端的依赖,降低系统资源占用,并简化部署过程。此外,对于那些使用ODBC兼容的编程语言(如C++、Python、PHP等)编写的应用...

    Oracle可视化工具sqldeveloper-23.1.0.097.1607-x64

    对于 PL/SQL 开发者,SQL Developer 提供了完整的开发环境,包括 PL/SQL 编辑器、调试器、PL/SQL 单元测试等功能,使得编写、调试和测试存储过程、函数、触发器等更加高效。 **6. 图形化数据库对象管理** SQL ...

    instantclient-basic-nt-11.2.0.3.0.zip

    3. **开发和调试PL/SQL代码**:使用PL/SQL Developer的内置编辑器、调试器和代码完成功能,可以方便地编写和调试PL/SQL存储过程、函数和触发器。 4. **性能监控**:虽然Oracle Instant Client本身并不提供复杂的...

    sqldeveloper-18.2.0.183.1748-macosx.app.zip

    SQL Developer对PL/SQL的支持使得用户可以直接在IDE内编写、测试和调试存储过程、触发器等。 4. **版本控制集成**:SQL Developer可以与常见的版本控制系统(如Git)集成,便于团队协作和版本管理。 5. **性能分析**...

    Oracle 插件 instantclient-sqlplus-windows.x64-12.2.0.1.0.zip

    4. **PL/SQL支持**:能够编写、执行和调试PL/SQL存储过程和函数。 5. **SQL历史记录**:保存执行过的SQL语句,便于重用和参考。 6. **实用工具**:提供数据库对象信息查询、用户权限检查等功能。 **安装与配置...

    oracle-instantclient-sqlplus-win32-11.2.0.1.0

    在11.2版本中,Oracle引入了一些新的特性和改进,例如更好的并行查询处理、更高效的存储过程执行以及增强了对大型对象(LOB)的支持等。 在"压缩包子文件的文件名称列表"中,我们看到有两个文件:flux-setup4.exe和...

    oracle官方64位客户端-instantclient-basic-windows.x64-12.2.0.1.0

    相比于传统的完整客户端,它只包含了运行Oracle数据库连接所需的基本组件,如OCI(Oracle Call Interface)、SQL*Net和一些必要的库文件,这样可以减少对系统资源的占用,提高应用性能,并简化安装过程。 该版本...

    instantclient-basic-linux.x64-21.1.0.0.0.zip

    它提供了Python DB-API 2.0兼容的接口,使Python开发者能够方便地在Oracle数据库上执行SQL语句和存储过程。 在压缩包内的文件列表中,我们看到两个文件: 1. `readme.txt` - 这通常是一个文本文件,包含了关于如何...

Global site tag (gtag.js) - Google Analytics