Query the total number of parameters passed by function in Oracle.

Source: Internet
Author: User
create or replace function GET_COUNT_ZS(deptcode  in varchar2, tablename in varchar2,bs in varchar2)return  varchar2is num varchar2(1000);c number;beginif(bs=0) then num:='select count(*) from '||tablename||' where  deptcode like '''||deptcode||'%''';end if;if(bs=1) thennum:='select count(*) from '||tablename||' where  deptcode like '''||deptcode||'%'''||' and  SFDTGL=1' ;end if;execute immediate num into   c;return c;end;

Second:

create or replace function GET_COU_SYQK(deptcode  in varchar2, SYZT in varchar2)return  varchar2isnum varchar2(1000);c number;beginnum:='select count(*) from t_fwcq where  deptcode like '''||deptcode||'%'' and sszthz = '''||SYZT||'''';execute immediate num into   c;return c;end;

The called SQL statement:

VaR STB = new stringbuilder (); Stb. append ("select"); Stb. append ("get_count_zs ('" + deptcode + "','t _ fwzc ', 0) as countzc"); Stb. append (", get_count_zs ('" + deptcode + "','t _ fwcq ', 0) as countfw"); Stb. append (", get_count_zs ('" + deptcode + "', 'zc _ DT ', 0) as countdt"); Stb. append (", get_count_zs ('" + deptcode + "','t _ fwzc ', 1) as countygl"); Stb. append (", get_cou_syqk ('" + deptcode + "', '') as countzy"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'id') as countxz"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'lease ') as countcz"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'occupies ') as countzhany"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'sold ') as countcs"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'disc deficient ') as countpk"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'archive ') as countfc"); Stb. append (", get_cou_syqk ('" + deptcode + "', 'others') as countyqt"); Stb. append ("from dual ");
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.