Skip to content

Instantly share code, notes, and snippets.

@xiyoulaoyuanjia
Created June 20, 2017 07:48
Show Gist options
  • Save xiyoulaoyuanjia/51530fab109444051131f974134e7d25 to your computer and use it in GitHub Desktop.
Save xiyoulaoyuanjia/51530fab109444051131f974134e7d25 to your computer and use it in GitHub Desktop.
dbaccess etl_db<<!
call test1();
!
drop function if exists fn_get_hl_t;
create function fn_get_hl_t(i_bz varchar(2)) returning decimal(16,10);
define hlzjjg decimal(16,10);
select case
when hbdw is null or hbdw=0 then 1
else zjjg/hbdw end case
into hlzjjg from etl_db:u_hlb_t
where dfbz='01'
and hbzl=i_bz
and hlzl='200';
--insert into log values(0);
return(nvl(hlzjjg,1));
end function;
drop table if exists u_hlb_t;
create table u_hlb_t
(hbzl varchar(2),
dfbz varchar(10),
hlzl varchar(10),
zjjg decimal(16,10),
hbdw decimal(16,10)
);
drop table if exists t1;
create table t1
(hbzl varchar(3),
dfbz varchar(10),
hlzl varchar(10),
zjjg decimal(16,10),
hbdw decimal(16,10)
);
insert into u_hlb_t select tabid::varchar(2),'01','200',tabid,tabid from systables where tabid<100;
drop procedure if exists insert_t;
create procedure insert_t()
define i int;
for i=1 to 100000
insert into t1 select * from u_hlb_t;
end for;
end procedure;
call insert_t();
--drop procedure if exists test;
--create procedure test()
--define c char(10);
--select * from t1 into temp tmp_t1;
--create index idx on tmp_t1(hbzl);
--set lock mode to not wait;
--set lock mode to wait;
--select fn_get_hl_t(hbzl) as hbzl,dfbz,hlzl,zjjg,hbdw from tmp_t1
--where hbzl <>'a'
--into temp tmp_t2;
--end procedure;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment