• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

笑看红尘

笑看红尘
  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

存储过程中结构体的使用.相当于数组

 type Type_BorrowID is table of varchar2(20); 定义一个表的一个varchar2(20)类型的一个字段
  type Type_Date is table of varchar2(14);
  type Type_Number is table of number(10, 2);
  type Type_Dept is table of number(4);
  type Type_Speed is table of number(10, 2);
  type Type_Status is table of char(1);
  type Type_ShelfID is table of NUMBER(4);
  type Type_DeliverRouteID is table of varchar2(20);

  type REC_PickStatusGather is record(
    t_BorrowID       Type_BorrowID,
    t_PickDate       Type_Date,
    t_PickTeamID     Type_Dept,
    t_PickBeginTime  Type_Date,
    t_PickEndTime    Type_Date,
    t_PickUseTime    Type_Date,
    t_CustomerNum    Type_Number,
    t_BarQuantity    Type_Number,
    t_PieceQuantity  Type_Number,
    t_BoxQuantity    Type_Number,
    t_PackQuantity   Type_Number,
    t_BarSpeed       Type_Speed,
    t_PackSpeed      Type_Speed,
    t_ShelfID        Type_ShelfID,
    t_DeliverRouteID Type_DeliverRouteID,
    t_DeliverID      Type_DeliverRouteID,
    t_Status         Type_Status);

  r_PickStatusGather REC_PickStatusGather;定义一个类似于struct的一个结构体,这里我把他称为一个记录集合,相当于临时的一个内存表.
sSQL := 'select distinct t1."BorrowID",TO_CHAR(t1."PickDate",''yyyymmdd''),t1."Status" from D_Route@' ||
            sDataSource ||
            ' t1, LTMP.TT_PIK_Borrow t2 where t1."BorrowID"=t2.BorrowID ';
    execute immediate sSQL bulk collect
      into r_PickStatusGather.t_BorrowID, r_PickStatusGather.t_PickDate, r_PickStatusGather.t_Status;
此段是向这个内存表里插入记录.
forall i in 1 .. r_PickStatusGather.t_BorrowID.count
      update LPMS.PIK_PickStatusGather
         set BarSpeed  = r_PickStatusGather.t_BarSpeed(i),
             PackSpeed = r_PickStatusGather.t_PackSpeed(i)
       where BorrowID = r_PickStatusGather.t_BorrowID(i);

    r_PickStatusGather.t_BarSpeed.delete;
    r_PickStatusGather.t_PackSpeed.delete;
    r_PickStatusGather.t_BorrowID.delete;
此段是对内存表的循环对表的更新操作

posted on 2006-08-04 09:45  孙彬  阅读(616)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3