<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Creativz Lab &#187; PL/SQL SPLIT</title>
	<atom:link href="http://creativeslab.net/tag/plsql-split/feed" rel="self" type="application/rss+xml" />
	<link>http://creativeslab.net</link>
	<description>weblog for Developers &#38; Designers</description>
	<lastBuildDate>Sun, 18 Jul 2010 16:37:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Split String using Oracle PL/SQL</title>
		<link>http://creativeslab.net/split-string-using-oracle-plsql</link>
		<comments>http://creativeslab.net/split-string-using-oracle-plsql#comments</comments>
		<pubDate>Thu, 25 Jun 2009 20:45:38 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Programming]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Strings]]></category>
		<category><![CDATA[pl/sql procedure]]></category>
		<category><![CDATA[PL/SQL SPLIT]]></category>
		<category><![CDATA[split string]]></category>
		<category><![CDATA[string functions]]></category>
		<category><![CDATA[string split]]></category>

		<guid isPermaLink="false">http://creativeslab.net/?p=47</guid>
		<description><![CDATA[Oracle PL/SQL provides various string functions, but there is no direct function to split a string into substrings, we need to write a custom code to do this task.]]></description>
			<content:encoded><![CDATA[<p>Oracle PL/SQL provides various string functions, but there is no direct function to split a string into substrings, where as 4GL languages have direct functions to split strings.</p>
<p>We can split a string into substrings using PL/SQL built in functions SUBSTR(), INSTR() and LENGTH() together.</p>
<p>Follwing code snippets helps you in splitting a string into substrings.</p>
<p>Snippet to split string into pieces:::</p>
<p><strong>CREATE OR REPLACE FUNCTION func_str_split(str_to_split   IN OUT VARCHAR2<br />
                 ,str_delimiter IN     VARCHAR2) RETURN VARCHAR2<br />
IS<br />
  t_pos   NUMBER;<br />
  t_len   NUMBER;<br />
  t_strlen   NUMBER;<br />
  t_strresult VARCHAR2(2000);<br />
BEGIN<br />
  t_strresult := NULL;<br />
  IF str_to_split IS NOT NULL THEN<br />
    t_len := LENGTH(str_delimiter);<br />
    t_strlen := LENGTH(str_to_split);<br />
    t_pos := INSTR(str_to_split,str_delimiter);<br />
    IF t_pos &gt; 0 THEN<br />
      t_strresult := SUBSTR(str_to_split,1,t_pos-1);<br />
      str_to_split := SUBSTR(str_to_split,t_pos+t_len,t_strlen);<br />
    ELSE<br />
      t_strresult := str_to_split;<br />
      str_to_split := NULL;<br />
    END IF;<br />
  END IF;<br />
  RETURN t_strresult;<br />
END func_str_split;</strong></p>
<p>Use following procedure to call above function:::</p>
<p><strong>CREATE OR REPLACE PROCEDURE proc_str_split(str_to_split   IN OUT VARCHAR2<br />
                 ,str_delimiter IN  VARCHAR2)<br />
IS<br />
 declare </p>
<p> RetVal varchar2(150);</p>
<p>BEGIN</p>
<p>WHILE str_to_split IS NOT NULL LOOP<br />
     RetVal := func_str_split ( str_to_split, str_delimiter );<br />
     dbms_output.put_line(RetVal);<br />
END LOOP;</p>
<p>END proc_str_split;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://creativeslab.net/split-string-using-oracle-plsql/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
