zoukankan      html  css  js  c++  java
  • Oracle 存储过程A

    create or replace procedure users_procedure is
      cursor users_cursor is select * from users;
      v_id users.id%type;
      v_username users.username%type;
      v_password users.password%type;
    begin
      open users_cursor;
      fetch users_cursor into v_id, v_username, v_password;
      while users_cursor%found
        loop
          dbms_output.put_line('v_id = ' || v_id || 'v_username = ' || v_username || 'v_password = ' || v_password);
          fetch users_cursor into v_id, v_username, v_password;
        end loop;
      close users_cursor;
    end;
    /
    
    
    create or replace procedure users_batch_insert_procedure is
      v_id users.id%type;
      v_username users.username%type;
      v_password users.password%type;
    begin
      for i in 0..1000
        loop
          v_id := i;
          v_username := 'abc' || i;
          v_password := 'efg' || i;
          insert into users values(v_id, v_username, v_password);
          commit;
        end loop;
    end;
    /
    
    create or replace procedure users_a is
      type users_cursor_type is ref cursor; --return users%rowtype;
      type users_record_type is record (v_id users.id%type, v_username users.username%type, v_password users.password%type);
      v_sql varchar2(2000);
      users_cursor_a users_cursor_type;
      users_record users_record_type;
    begin
      v_sql := 'select * from users';
      open users_cursor_a for v_sql;
      fetch users_cursor_a into users_record;
      while users_cursor_a%found
        loop
          dbms_output.put_line('v_id = ' || users_record.v_id || 'v_username = ' || users_record.v_username || 'v_password = ' || users_record.v_password);
          fetch users_cursor_a into users_record;
        end loop;
      close users_cursor_a;
    end;
    /
    
    create or replace procedure users_a is
      type users_cursor_type is ref cursor return users%rowtype;
      v_row users%rowtype;
      v_sql varchar2(2000);
      users_cursor_a users_cursor_type;
    begin
      
      open users_cursor_a for select * from users;
      fetch users_cursor_a into v_row;
      while users_cursor_a%found
        loop
          dbms_output.put_line('v_id = ' || v_row.id || 'v_username = ' || v_row.username || 'v_password = ' || v_row.password);
          fetch users_cursor_a into v_row;
        end loop;
      close users_cursor_a;
    end;
    /
    
    set serveroutput on size 1000000;
    
  • 相关阅读:
    find指令使用手册
    IP封包协议头/TCP协议头/TCP3次握手/TCP4次挥手/UDP协议头/ICMP协议头/HTTP协议(请求报文和响应报文)/IP地址/子网掩码(划分子网)/路由概念/MAC封包格式
    Vmare虚拟机中的3种网络连接方式
    Windows10下Apache2.4配置Django
    网站配色
    js 图片轮播
    Window10下Apache2.4的安装和运行
    sqlite数据库转换为mysql数据库
    windows10 安装 mysql 5.6 教程
    win10 nginx + django +flup 配置
  • 原文地址:https://www.cnblogs.com/dingyingsi/p/3385395.html
Copyright © 2011-2022 走看看