title: Error in stored procedure while adding routine in phpmyadmin
body: <p>I am getting error while adding routine in <code>phpmyadmin.whenever</code> I try to add code in add routine then I receive error in whole code given below.</p>
  
  <p>My code for stored procedure is:</p>
  
  <pre><code>BEGIN
  
  SET @LocationType   = _locationType;
  SET @LocationId     = _locationId;
  SET @LocationMaster = _locationMaster;
  SET @CategoryId     = _categoryId;
  
  SET @SELECTQUERY = " select SalesChannel.name , Transaction.category_id, count(Transaction.category_id) as count from outlets Outlet inner join transactions Transaction on Outlet.id = Transaction.outlet_id inner join sale_channels SalesChannel on SalesChannel.id = Outlet.sale_channel_id  ";
  
  
  
      SET @WHEREQUERY = " WHERE TRUE = TRUE ";
  
      SET @GROUPBY = "";
  
      IF @LocationType is NOT NULL AND @LocationType != '' AND @LocationType == 'zone' THEN
          SET @WHEREQUERY = CONCAT(@WHEREQUERY, ' AND Outlet.zone_id  = @LocationId ');
      END IF;
  
      IF @LocationType is NOT NULL AND @LocationType != '' AND @LocationType == 'state' THEN
          SET @WHEREQUERY = CONCAT(@WHEREQUERY, ' AND Outlet.state_id  = @LocationId ');
      END IF;
  
      IF @LocationType is NOT NULL AND @LocationType != '' AND @LocationType == 'city' THEN
          SET @WHEREQUERY = CONCAT(@WHEREQUERY, ' AND Outlet.city_id  = @LocationId ');
      END IF;
  
      IF @LocationMaster is NOT NULL AND @LocationMaster != '' AND @LocationMaster == 'zone' THEN
          SET @WHEREQUERY = CONCAT(@WHEREQUERY, ' AND Outlet.zone_id  = @LocationId ');
      END IF;
  
      IF @CategoryId is NOT NULL AND @CategoryId != '' THEN
          SET @WHEREQUERY = CONCAT(@WHEREQUERY, ' AND Transaction.category_id  = @CategoryId ');
      END IF;
  
      SET @GROUPBY =  CONCAT(@GROUPBY, ' GROUP BY Transaction.category_id');
  
      SET @SQLQUERY = CONCAT(@SELECTQUERY , @WHEREQUERY, @GROUPBY);
  
      PREPARE state1  FROM @SQLQUERY;
  
      EXECUTE state1;
  
  END
  </code></pre>
  
  <p>I am using here two tables , the structures of the tables are given below. 1 Transactions 2. outlets</p>
  
  <pre><code>    CREATE TABLE IF NOT EXISTS `transactions` (
      `id` int(11) NOT NULL,
        `zone_id` int(11) NOT NULL,
        `state_id` int(11) NOT NULL,
        `city_id` int(11) NOT NULL,
        `category_id` int(11) NOT NULL,
        `sub_category_id` int(11) NOT NULL,
        `brand_id` int(11) NOT NULL,
        `model_id` int(11) NOT NULL,
        `outlet_id` int(11) NOT NULL,
        `no_of_units` int(11) NOT NULL,
        `mop` decimal(10,2) NOT NULL
      ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
  
      --
      -- Dumping data for table `transactions`
      --
  
      INSERT INTO `transactions` (`id`, `zone_id`, `state_id`, `city_id`, `category_id`, `sub_category_id`, `brand_id`, `model_id`, `outlet_id`, `no_of_units`, `mop`) VALUES
      (1, 2, 2, 2, 2, 1, 1, 1, 1, 3, '6.00'),
      (2, 2, 2, 2, 2, 1, 1, 1, 1, 3, '6.00'),
      (3, 1, 1, 1, 1, 1, 1, 1, 1, 4, '2.00'),
      (4, 2, 2, 2, 1, 1, 1, 1, 2, 4, '2.00');
  
      --
      -- Indexes for dumped tables
      --
  
  &lt;/code&gt;
  &lt;code&gt;
  
  
  CREATE TABLE IF NOT EXISTS `outlets` (
  `id` int(11) NOT NULL,
    `outlet_code` varchar(255) NOT NULL,
    `name` varchar(255) NOT NULL,
    `zone_id` int(11) NOT NULL,
    `state_id` int(11) NOT NULL,
    `city_id` int(11) NOT NULL,
    `sale_channel_id` int(11) NOT NULL,
    `is_active` tinyint(1) NOT NULL,
    `created` datetime NOT NULL,
    `modified` datetime NOT NULL
  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `outlets`
  --
  
  INSERT INTO `outlets` (`id`, `outlet_code`, `name`, `zone_id`, `state_id`, `city_id`, `sale_channel_id`, `is_active`, `created`, `modified`) VALUES
  (1, '1508', 'Ashok electricals', 2, 2, 2, 1, 1, '2016-10-03 00:00:00', '2016-10-03 00:00:00'),
  (2, '1233', 'vinayak electricals', 1, 1, 1, 2, 1, '2016-10-04 00:00:00', '2016-10-04 00:00:00');
  </code></pre>