table of number index by varchar2(100)

--字符串序列要这样
declare
    type t   istable of number(3) indexby varchar2(3);
   hash_t t;  
   l_row varchar2(3);
  begin
  hash_t('a') := 10;
  hash_t('b') := 20;  
  l_row :=hash_t.first;
  while(l_rowisnot null) loop
  dbms_output.put_line(hash_t(l_row));
  l_row:=hash_t.next(l_row);
  endloop;
  end;
--数字序列可以这样
declare
    type t   istable of number(3) indexby pls_integer;
   hash_t t;  
   l_row varchar2(3);
  begin
  hash_t(1) := 10;
  hash_t(2) := 20;  
  fori inhash_t.first.. hash_t.lastloop
  dbms_output.put_line(hash_t(i));
  endloop;
  end;



语句:type  numbers  is table of number index by binary_integer;其作用是,加了”index by binary_integer ”后,numbers类型的下标就是自增长,
可以自动根据下标找到对应的值。numbers类型在插入元素时,不需要初始化,不需要每次extend增加一个空间。
  而如果没有这句话“index by binary_integer”,那就得要显示对初始化,且每插入一个元素到numbers类型的table中时,都需要先extend.
   没加“index by binary_integer”时:
  declare
  type numbers is table of number;
  m   numbers := numbers();
  begin
  m.extend;
  m(1) := 2;
  m.extend;
  m(2) := 3;
  for i in1 .. m.count loop
  dbms_output.put_line(m(i));
  end loop;
  end;
  输出:2,3
  而如果加了“index by binary_integer”,代码如下写就可以达到上面的效果
      declare 
 type numbers is table of number index by binary_integer;
      m numbers;
    begin
      m(1) := 2;
     m(2) := 3;
      for i in 1..m.count loop
      dbms_output.put_line(m(i));
     end loop;
  end;


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码是什么意思-- Create table create table CUX_WMS_PO_TRANSACTION_HEADER ( erp_message_no VARCHAR2(60) not null, po_number VARCHAR2(20) not null, erp_order_type VARCHAR2(20) not null, org_code VARCHAR2(20) not null, header_id NUMBER not null, supplier_code VARCHAR2(240) not null, asn_num VARCHAR2(200) not null, last_update_date DATE, last_updated_by NUMBER, creation_date DATE, created_by NUMBER, last_update_login NUMBER, operatives VARCHAR2(50) not null, return_code VARCHAR2(200), return_mesg VARCHAR2(400), isinwarehouse NUMBER, remark VARCHAR2(200), character5 VARCHAR2(200), isinspectionresults NUMBER, remark2 VARCHAR2(150), remark3 VARCHAR2(150), remark4 VARCHAR2(150) ) tablespace APPS_TS_TX_DATA pctfree 10 initrans 1 maxtrans 255 storage ( initial 16K next 8K minextents 1 maxextents unlimited pctincrease 0 ); -- Add comments to the columns comment on column CUX_WMS_PO_TRANSACTION_HEADER.erp_message_no is '接口编号'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.po_number is '采购订单号'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.erp_order_type is '事务处理类型'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.org_code is 'OU-ID'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.header_id is '采购订单头id'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.supplier_code is '供应商编码'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.asn_num is 'wms号'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.operatives is '操作员'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.return_code is '反馈代码'; comment on column CUX_WMS_PO_TRANSACTION_HEADER.return_mesg is '反馈信息'; -- Create/Recreate indexes create index WMS_PO_TRANSACTION_HEADER_N1 on CUX_WMS_PO_TRANSACTION_HEADER (CREATION_DATE, DECODE(RETURN_CODE,'S','S','E')) tablespace APPS_TS_TX_DATA pctfree 10 initrans 2 maxtrans 255 storage ( initial 64K next 128K minextents 1 maxextents unlimited pctincrease 0 ); create unique index WMS_PO_TRANSACTION_HEADER_U1 on CUX_WMS_PO_TRANSACTION_HEADER (ERP_MESSAGE_NO) tablespace APPS_TS_TX_DATA pctfree 10 initrans 2 maxtrans 255 storage ( initial 64K next 128K minextents 1 maxextents unlimited pctincrease 0 );
最新发布
06-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值