遇到一个问题,如何将ORACLE中的函数引入到mysql中?  以下是该函数:
create or replace function f_get_Item_Accounts(p_gsdm in varchar2,p_xmdm in varchar2,p_kmbh in varchar2,p_date in varchar2,p_bz in varchar2,p_zhxz in varchar2,p_type in varchar2) return number is  --科目余额初始化时根据条件计算汇总科目对应的数量、金额
  --p_gsdm 公司代码
  --p_xmdm 项目代码  '00000000' 非项目
  --p_kmbh 科目编号
  --p_date 业务日期-初始化日期
  --p_bz   币种
  --p_zhxz 帐户性质 '01'银行帐务 ,'02' 交易帐户
  --p_type '01'-期初余额,'02'-期初数量,'03'-借方发生额,'04'-贷方发生额,'05'-借方发生数量,'06'-贷方发生数量,'07'-期末数量 '08'-期末余额,'10'-子科目个数
   Result               number ;
   v_sql                varchar2(2000);
   r1                   integer;
   c1                   integer;
   v_str                varchar2(300);
   v_result              varchar(30):='0';
begin
  if p_type='01' then
  v_str:='nvl(sum(qcye),0)';
  end if;
  if p_type='02' then
  v_str:='nvl(sum(qcsl),0)';
  end if;
  if p_type='03' then
  v_str:='nvl(sum(jffse),0)';
  end if;
  if p_type='04' then
  v_str:='nvl(sum(dffse),0)';
  end if;
  if p_type='05' then
  v_str:='nvl(sum(jffssl),0)';
  end if;
  if p_type='06' then
  v_str:='nvl(sum(dffssl),0)';
  end if;
  if p_type='07' then
  v_str:='nvl(sum(qmsl),0)';
  end if;
  if p_type='08' then
  v_str:='nvl(sum(qmye),0)';
  end if;
   if p_type='10' then
  v_str:='count(1)';
  end if;
  if p_type='01'  or p_type='02' then
   v_sql:='select '||v_str||' from kmyeb where gsdm='''||p_gsdm||''' and xmdm='''||p_xmdm||''' and kjkm like '''||p_kmbh||'%''  and ywrq=to_date('''||p_date||''',''yyyy-mm-dd'') and bz='''||p_bz||''' and zhxz='''||p_zhxz||'''';
  end if;
  if p_type>'02'  and  p_type<'10' then
  v_sql:='select '||v_str||' from kmyeb where gsdm='''||p_gsdm||''' and xmdm='''||p_xmdm||''' and kjkm like '''||p_kmbh||'%''  and ywrq=to_date('''||p_date||''',''yyyy-mm-dd'') and bz='''||p_bz||''' and zhxz='''||p_zhxz||'''';
  end if;
  if p_type='10' then
   v_sql:='select '||v_str||' from kmyeb where gsdm='''||p_gsdm||''' and xmdm='''||p_xmdm||''' and kjkm like '''||p_kmbh||'%'' and kjkm<>'''||p_kmbh||'''  and ywrq=to_date('''||p_date||''',''yyyy-mm-dd'') and bz='''||p_bz||''' and zhxz='''||p_zhxz||'''';
  end if;
  c1 := dbms_sql.open_cursor;
  dbms_sql.parse(c1,v_sql,dbms_sql.native);--定义游标
  dbms_sql.define_column(c1,1,v_result,20);--定义相关字段
  r1 := dbms_sql.execute(c1); --执行c1游标对应的select语句
  r1 := dbms_sql.fetch_rows(c1); --第一次fetch
  dbms_sql.column_value(c1,1,v_result);
  dbms_sql.close_cursor(c1); --关闭游标
  Result:=to_number(v_result);
  return(Result);
end f_get_Item_Accounts ;
只要把它变成mysql上的就成。