title: How to create a function using MySQL Workbench?
body: <p>I have an MSSQL background.</p>
  
  <p>I am trying to create a function in MySQL Workbench by rightclicking on <code>'Functions' &gt; 'Create Function'</code>.</p>
  
  <p>I insert this text to create the function into the window but it says there are errors in sql at the last line <code>missing 'if'</code>.(SQL below). What am I missing?</p>
  
  <p>2nd Qn. (Related)</p>
  
  <p>If I create the function using the function SQL (not using the menu in MySQL Workbench), the function gets created but it doesn't appear in the 'Functions' being shown in the schema am working on.
  What is the recommended way to create functions in MySQL Workbench?</p>
  
  <p>Thanks.</p>
  
  <pre><code>CREATE FUNCTION fnIsExcluded(ConcattedString NVARCHAR(15), InValue DECIMAL)
  RETURNS BIT 
  
  BEGIN 
      DECLARE individual VARCHAR(20) DEFAULT NULL;
      DECLARE ReturnValue BIT;
  
      IF (LENGTH(ConcattedString)) &lt; 1
          THEN
              SET ReturnValue = 0;
  
  
      ELSE IF ConcattedString IS NULL
      THEN
          SET ReturnValue = 0;
  
  
      ELSE IF InValue IS NULL
      THEN
  
          SET ReturnValue = 0;
  
      ELSE
       SET ReturnValue = 1;
  
      END IF;
  
       RETURN ReturnValue;
  
  END;
  </code></pre>