title: mariaDB syntax error (stored procedure with if statement and parameters)
body: <blockquote>
    <p>Hello and Good day..
    I need some help on my stored procedures query using shell or cmd.`
    This is my bookAuthor table</p>
  </blockquote>
  
  <pre><code>+-------------+-------------+------+-----+---------+----------------+
  | Field       | Type        | Null | Key | Default | Extra          |
  +-------------+-------------+------+-----+---------+----------------+
  | authorID    | int(11)     | NO   | PRI | NULL    | auto_increment |
  | authorLname | varchar(50) | YES  |     | NULL    |                |
  | authorFname | varchar(50) | YES  |     | NULL    |                |
  | authorMname | varchar(50) | YES  |     | NULL    |                |
  +-------------+-------------+------+-----+---------+----------------+`
  </code></pre>
  
  <blockquote>
    <p>If i use a single operation without if statement like the query below it works fine</p>
  </blockquote>
  
  <pre><code> MariaDB [library]&gt; create procedure selectAll()
      -&gt; select * from bookAuthor;
  Query OK, 0 rows affected (0.60 sec)
  </code></pre>
  
  <blockquote>
    <p>But if i use an if statement and put a parameters like the query below</p>
  </blockquote>
  
  <pre><code> MariaDB [library]&gt; create procedure insertUpdateSelectDelete
      -&gt; (
      -&gt; id int(11),
      -&gt; lname varchar(50),
      -&gt; fname varchar(50),
      -&gt; mname varchar(50),
      -&gt; statementtype varchar(30)
      -&gt; )
      -&gt; if statementtype = 'Insert'
      -&gt; insert into bookAuthor
      -&gt; (
      -&gt; authorLname,
      -&gt; authorFname,
      -&gt; authorMname
      -&gt; )
      -&gt; values
      -&gt; (
      -&gt; lname,
      -&gt; fname,
      -&gt; mname
      -&gt; )
      -&gt; if statementtype = 'Update'
      -&gt; update bookAuthor set
      -&gt; authorLname = lname,
      -&gt; authorFname = fname,
      -&gt; authorMname = mname
      -&gt; where authorID = id
      -&gt; if statementtype = 'Select'
      -&gt; select * from bookAuthor
      -&gt; if statementtype = 'Delete'
      -&gt; delete from bookAuthor where authorID = id;
  </code></pre>
  
  <blockquote>
    <p>it will return an error like this</p>
  </blockquote>
  
  <pre><code> ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'insert into bookAuthor
  (
  authorLname,
  authorFname,
  authorMname
  )
  values
  (
  lname,' at line 10
  </code></pre>