<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MySQL Stored procedure – Split Delimited string into Rows</title>
	<atom:link href="http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/feed" rel="self" type="application/rss+xml" />
	<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows</link>
	<description>Kedar&#039;s Blog for MySQL and more</description>
	<lastBuildDate>Fri, 27 Jan 2012 04:35:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Kedar</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-3559</link>
		<dc:creator>Kedar</dc:creator>
		<pubDate>Tue, 17 Jan 2012 11:13:27 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-3559</guid>
		<description>Sneha,

I think you can do that using LIMIT for splitter_cur cursor.

Eg. process 10000 records as:

DECLARE splitter_cur CURSOR FOR
SELECT id,cat from tmp limit 10000;

Hope this helps,
Kedar.</description>
		<content:encoded><![CDATA[<p>Sneha,</p>
<p>I think you can do that using LIMIT for splitter_cur cursor.</p>
<p>Eg. process 10000 records as:</p>
<p>DECLARE splitter_cur CURSOR FOR<br />
SELECT id,cat from tmp limit 10000;</p>
<p>Hope this helps,<br />
Kedar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sneha</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-3556</link>
		<dc:creator>sneha</dc:creator>
		<pubDate>Tue, 17 Jan 2012 10:55:37 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-3556</guid>
		<description>Thanks guys, this code worked great.
but i have 11,00,000 records to split,  i feel its better to do in batches. Please help me to do it</description>
		<content:encoded><![CDATA[<p>Thanks guys, this code worked great.<br />
but i have 11,00,000 records to split,  i feel its better to do in batches. Please help me to do it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kedar</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-3519</link>
		<dc:creator>Kedar</dc:creator>
		<pubDate>Sat, 24 Dec 2011 06:13:05 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-3519</guid>
		<description>Hey MIchael,

I&#039;d like to know your exact scenario!
Meanwhile make sure you&#039;re not copying procedure from page but downloading it from the link.
Once procedure get loaded into db, you may uncomment some of the lines to debug through!

Cheers,
Kedar</description>
		<content:encoded><![CDATA[<p>Hey MIchael,</p>
<p>I&#8217;d like to know your exact scenario!<br />
Meanwhile make sure you&#8217;re not copying procedure from page but downloading it from the link.<br />
Once procedure get loaded into db, you may uncomment some of the lines to debug through!</p>
<p>Cheers,<br />
Kedar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-3516</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 23 Dec 2011 15:08:41 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-3516</guid>
		<description>Thanks a lot for the procedure, extremely useful. I have a little problem and I would like to ask you for help: when I run it on one of my table I get this error &quot; Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;NULL&#039; at line 1&quot;
And I am really not able to figure out what could it be due to. I get some result in the table &quot;my_splits&quot; (removed the tempoary). I also tried to set  both `splitted_column` and &#039;id&#039; to  &quot;default NULL&quot;, but I continue to get that error. Any idea? Thank you very much.</description>
		<content:encoded><![CDATA[<p>Thanks a lot for the procedure, extremely useful. I have a little problem and I would like to ask you for help: when I run it on one of my table I get this error &#8221; Error Code: 1064<br />
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#8216;NULL&#8217; at line 1&#8243;<br />
And I am really not able to figure out what could it be due to. I get some result in the table &#8220;my_splits&#8221; (removed the tempoary). I also tried to set  both `splitted_column` and &#8216;id&#8217; to  &#8220;default NULL&#8221;, but I continue to get that error. Any idea? Thank you very much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WebTechTuts</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-3266</link>
		<dc:creator>WebTechTuts</dc:creator>
		<pubDate>Sat, 23 Jul 2011 14:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-3266</guid>
		<description>I really like this post. This really saves lots of time.</description>
		<content:encoded><![CDATA[<p>I really like this post. This really saves lots of time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-1728</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Thu, 16 Dec 2010 14:20:10 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-1728</guid>
		<description>This just saved me tons of time.  Thanks!!</description>
		<content:encoded><![CDATA[<p>This just saved me tons of time.  Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arno</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-2#comment-1087</link>
		<dc:creator>Arno</dc:creator>
		<pubDate>Wed, 24 Nov 2010 04:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-1087</guid>
		<description>Hi Thanks it works.

Now, I had to use _space_ as delimiter, something that did not work very well with the above.

But doing a replace &quot; &quot; -&gt; &quot;;&quot; on the select fixes that.

SELECT id,REPLACE(cat, &#039; &#039;, &#039;;&#039;) from tmp;</description>
		<content:encoded><![CDATA[<p>Hi Thanks it works.</p>
<p>Now, I had to use _space_ as delimiter, something that did not work very well with the above.</p>
<p>But doing a replace &#8221; &#8221; -&gt; &#8220;;&#8221; on the select fixes that.</p>
<p>SELECT id,REPLACE(cat, &#8216; &#8216;, &#8216;;&#8217;) from tmp;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heba</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-78</link>
		<dc:creator>heba</dc:creator>
		<pubDate>Tue, 21 Sep 2010 10:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-78</guid>
		<description>happy to help :)
actually i reached this solution out by luck :s
i tried removing lines one by one untill it worked... then i realized that execute command is the reason of the problem..

but seems like u have a proof of that and have more information about it.. u can tell me any info if u dont mind.. i&#039;m starting with stored procedures these days..

thanks in advance
and many thanks to the author Kedar :):)</description>
		<content:encoded><![CDATA[<p>happy to help <img src='http://kedar.nitty-witty.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
actually i reached this solution out by luck :s<br />
i tried removing lines one by one untill it worked&#8230; then i realized that execute command is the reason of the problem..</p>
<p>but seems like u have a proof of that and have more information about it.. u can tell me any info if u dont mind.. i&#8217;m starting with stored procedures these days..</p>
<p>thanks in advance<br />
and many thanks to the author Kedar <img src='http://kedar.nitty-witty.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heba</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-76</link>
		<dc:creator>heba</dc:creator>
		<pubDate>Mon, 20 Sep 2010 14:29:37 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-76</guid>
		<description>i figured out that EXECUTE command is the reason of my problem.. i removed it and worked around it.. it inserts successfully now..
i replaced this part :
//
SET ins_query=concat(“insert into my_splits(splitted_column,id) values(“, concat(“SUBSTRING_INDEX(SUBSTRING_INDEX( ‘”,split_string ,”‘, ‘”,my_delimiter,”‘, “,i, “),’”,my_delimiter,”‘,-1),”,split_id,”);”));
set @ins_query=ins_query;
PREPARE ins_query from @ins_query;
EXECUTE ins_query;
//

with this part
//
SET ins_query= SUBSTRING_INDEX(SUBSTRING_INDEX( split_string, my_delimiter, i),my_delimiter,-1);
        set @ins_query=ins_query;
        insert into my_splits values(@ins_query,split_id);
//

thanks :)</description>
		<content:encoded><![CDATA[<p>i figured out that EXECUTE command is the reason of my problem.. i removed it and worked around it.. it inserts successfully now..<br />
i replaced this part :<br />
//<br />
SET ins_query=concat(“insert into my_splits(splitted_column,id) values(“, concat(“SUBSTRING_INDEX(SUBSTRING_INDEX( ‘”,split_string ,”‘, ‘”,my_delimiter,”‘, “,i, “),’”,my_delimiter,”‘,-1),”,split_id,”);”));<br />
set @ins_query=ins_query;<br />
PREPARE ins_query from @ins_query;<br />
EXECUTE ins_query;<br />
//</p>
<p>with this part<br />
//<br />
SET ins_query= SUBSTRING_INDEX(SUBSTRING_INDEX( split_string, my_delimiter, i),my_delimiter,-1);<br />
        set @ins_query=ins_query;<br />
        insert into my_splits values(@ins_query,split_id);<br />
//</p>
<p>thanks <img src='http://kedar.nitty-witty.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kedar</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-75</link>
		<dc:creator>Kedar</dc:creator>
		<pubDate>Mon, 20 Sep 2010 11:48:18 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-75</guid>
		<description>If you google this you&#039;ll find many of the times this has to do with older versions... Please check versions...

Also, Do make sure you make proper changes to SP as per your requirements.

May be you can share sample data on db4free.net to get it clear!</description>
		<content:encoded><![CDATA[<p>If you google this you&#8217;ll find many of the times this has to do with older versions&#8230; Please check versions&#8230;</p>
<p>Also, Do make sure you make proper changes to SP as per your requirements.</p>
<p>May be you can share sample data on db4free.net to get it clear!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heba</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-74</link>
		<dc:creator>heba</dc:creator>
		<pubDate>Mon, 20 Sep 2010 08:08:36 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-74</guid>
		<description>Kadar,
thanks for your reply.
actually i had tried a very simple statement like that insert statement and it worked fine.
but when i try the whole stored it gives me the mentioned error.
i tried to figure out which part of it that causes that error but i couldn&#039;t cause it&#039;s my first time with stored procedures with mysql and phpmyadmin.

========================================
&#124;&#124;&#039;Let me know how you’re using this.&#039;&#124;&#124;
========================================

i created the stored in phpmyadmin and then called it in phpmyadmin too. i&#039;m trying to use the stored to split a string in one row in x table into multiple rows in y table.</description>
		<content:encoded><![CDATA[<p>Kadar,<br />
thanks for your reply.<br />
actually i had tried a very simple statement like that insert statement and it worked fine.<br />
but when i try the whole stored it gives me the mentioned error.<br />
i tried to figure out which part of it that causes that error but i couldn&#8217;t cause it&#8217;s my first time with stored procedures with mysql and phpmyadmin.</p>
<p>========================================<br />
||&#8217;Let me know how you’re using this.&#8217;||<br />
========================================</p>
<p>i created the stored in phpmyadmin and then called it in phpmyadmin too. i&#8217;m trying to use the stored to split a string in one row in x table into multiple rows in y table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kedar</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-73</link>
		<dc:creator>Kedar</dc:creator>
		<pubDate>Sat, 18 Sep 2010 15:21:30 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-73</guid>
		<description>Heba,
I&#039;m not sure how you&#039;re using this, but this is very shallow example and not at-all generalized. You might need to update it as per your requirements.

Try below table definition:

CREATE TABLE `tmp` (
  `id` int(11) DEFAULT NULL,
  `cat` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

insert into tmp values(1,&#039;a;b;c&#039;),(2,&#039;d;e;f&#039;),(3,&#039;y;z&#039;);

And run procedure from prompt or other way.

Let me know how you&#039;re using this.</description>
		<content:encoded><![CDATA[<p>Heba,<br />
I&#8217;m not sure how you&#8217;re using this, but this is very shallow example and not at-all generalized. You might need to update it as per your requirements.</p>
<p>Try below table definition:</p>
<p>CREATE TABLE `tmp` (<br />
  `id` int(11) DEFAULT NULL,<br />
  `cat` varchar(10) DEFAULT NULL<br />
) ENGINE=MyISAM DEFAULT CHARSET=latin1;</p>
<p>insert into tmp values(1,&#8217;a;b;c&#8217;),(2,&#8217;d;e;f&#8217;),(3,&#8217;y;z&#8217;);</p>
<p>And run procedure from prompt or other way.</p>
<p>Let me know how you&#8217;re using this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heba</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-72</link>
		<dc:creator>heba</dc:creator>
		<pubDate>Sat, 18 Sep 2010 13:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-72</guid>
		<description>it&#039;s a very useful piece of code .. thank u.. but atually i&#039;m unable to call the procedure coz i get this error : #1312 - PROCEDURE  can&#039;t return a result set in the given context .. do u have any idea about the solution..</description>
		<content:encoded><![CDATA[<p>it&#8217;s a very useful piece of code .. thank u.. but atually i&#8217;m unable to call the procedure coz i get this error : #1312 &#8211; PROCEDURE  can&#8217;t return a result set in the given context .. do u have any idea about the solution..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: booman</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-70</link>
		<dc:creator>booman</dc:creator>
		<pubDate>Fri, 17 Sep 2010 13:35:45 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-70</guid>
		<description>thank you! these lines of code saved me a lot of work...</description>
		<content:encoded><![CDATA[<p>thank you! these lines of code saved me a lot of work&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierinux</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-66</link>
		<dc:creator>Pierinux</dc:creator>
		<pubDate>Sat, 12 Jun 2010 13:59:55 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-66</guid>
		<description>thank you very much for the tip. I&#039;m using this technique on a project I will soon release as GPL, an opensource subscription manager for small magazines. your procedure is very useful in my project to build the delivery packing list, piking up the list of magazine numbers subscribed from a comma-separated list. I will credit your work as soon as it is ready. cheers! pierinux</description>
		<content:encoded><![CDATA[<p>thank you very much for the tip. I&#8217;m using this technique on a project I will soon release as GPL, an opensource subscription manager for small magazines. your procedure is very useful in my project to build the delivery packing list, piking up the list of magazine numbers subscribed from a comma-separated list. I will credit your work as soon as it is ready. cheers! pierinux</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kedar</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-65</link>
		<dc:creator>Kedar</dc:creator>
		<pubDate>Tue, 16 Feb 2010 10:12:25 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-65</guid>
		<description>@Marc: Thanks for pointing that out.
Images are now fixed.</description>
		<content:encoded><![CDATA[<p>@Marc: Thanks for pointing that out.<br />
Images are now fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc</title>
		<link>http://kedar.nitty-witty.com/blog/mysql-stored-procedure-split-delimited-string-into-rows/comment-page-1#comment-64</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Mon, 15 Feb 2010 21:15:30 +0000</pubDate>
		<guid isPermaLink="false">http://kedar.nitty-witty.com/blog/?p=290#comment-64</guid>
		<description>I would love to see the screenshots that you&#039;re linking to in this post but the links are dead. Can you relink for me?

kedar.nitty-witty.com/blog/wp-content/uploads/2009/12/source-table.JPG

kedar.nitty-witty.com/blog/wp-content/uploads/2009/12/output-table.jpg

Thanks!</description>
		<content:encoded><![CDATA[<p>I would love to see the screenshots that you&#8217;re linking to in this post but the links are dead. Can you relink for me?</p>
<p>kedar.nitty-witty.com/blog/wp-content/uploads/2009/12/source-table.JPG</p>
<p>kedar.nitty-witty.com/blog/wp-content/uploads/2009/12/output-table.jpg</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

