Hi, I have this function in Oracle, how could I migrate it to mysql? I understand that the syntax is similar but this function does not find it familiar.

Thank you

FUNCTION F_GET_TABLE_NAME(TABLE_NAME VARCHAR2, COL1 VARCHAR2, COL2 VARCHAR2,CHOICECOL NUMBER, GROUP_CD VARCHAR2, STAT_FLAG VARCHAR2) RETURN VARCHAR2 IS
TMPVAR VARCHAR2(70);
TMPSQL VARCHAR2(300);
BEGIN
  TMPVAR := NULL;

  IF GROUP_CD != 'N' THEN
      IF STAT_FLAG != 'N' THEN
          TMPSQL := 'SELECT  '||COL2||' FROM '||TABLE_NAME||'  WHERE '||COL1||' = '''||CHOICECOL||''' AND GROUP_CD = '''||GROUP_CD||''' AND STAT_CD = ''1000'' ORDER BY  '||COL2;
      ELSE
          TMPSQL := 'SELECT  '||COL2||' FROM '||TABLE_NAME||'  WHERE '||COL1||' = '''||CHOICECOL||''' AND GROUP_CD = '''||GROUP_CD||''' ORDER BY  '||COL2;                
      END IF;

  ELSE
      IF STAT_FLAG != 'N' THEN
          TMPSQL := 'SELECT  '||COL2||' FROM '||TABLE_NAME||'  WHERE '||COL1||' = '''||CHOICECOL||''' AND STAT_CD = ''1000'' ORDER BY  '||COL2;
      ELSE
          TMPSQL := 'SELECT  '||COL2||' FROM '||TABLE_NAME||'  WHERE '||COL1||' = '''||CHOICECOL||''' ORDER BY  '||COL2;                
      END IF;

  END IF;

  EXECUTE IMMEDIATE TMPSQL INTO TMPVAR;

  RETURN TMPVAR;

  EXCEPTION
      WHEN NO_DATA_FOUND THEN return '';
      WHEN OTHERS THEN return 'CODE ERROR';
END;