How to Convert oracle custom functions to mysql functions

Source: Internet
Author: User
Tags mysql functions
This is an oracle-defined function. how can we convert it to mysql worker (in_taskIdvarchar2, in_work_novarchar2) returnvarchar2isv_sumnumber (10); -- Average quality inspection completion quantity v_numNUMBER (10 ); -- individual QC completion quantity v_qualitied_cntNUMBER (10); v_resultvarchar2 (20); -- 0 exception, 1 is higher than the average... mysqloracle functions

This is a custom oracle function. how can I convert it to mysql?
Create or replace function fun_return_zjxl (in_taskId varchar2,
In_work_no varchar2)
Return varchar2 is
V_sum number (10); -- Average quality inspection completion volume
V_num NUMBER (10); -- quantity of individual QC completions
V_qualitied_cnt NUMBER (10 );
V_result varchar2 (20); -- 0 exception, 1 is higher than average, 2 is lower than average
Begin
V_result: = 0;
Select (SELECT count (*) FROM ZJ_SCORE zs where zs. TASK_ID = in_taskId and zs. status = 3)/(select count (zut. user_id) from zj_user_task zut where zut. task_id = in_taskId) into v_sum from dual;
SELECT count (zs. id) into v_num FROM ZJ_SCORE zs where zs. TASK_ID = in_taskId and zs. status = 3 and zs. work_no = in_work_no;
If (v_num> = v_sum) then
V_result: = 1;
Else
V_result: = 2;
End if;
Return (v_result );
End fun_return_zjxl;

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.