<?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>bigjim-network &#187; delimited</title>
	<atom:link href="http://bigjim-network.be/tag/delimited/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigjim-network.be</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 06:32:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PLSQL functions for delimited strings</title>
		<link>http://bigjim-network.be/2009/03/20/plsql-functions-for-delimited-strings/</link>
		<comments>http://bigjim-network.be/2009/03/20/plsql-functions-for-delimited-strings/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 19:22:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[oracle]]></category>
		<category><![CDATA[delimited]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[plsql]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://bigjim-network.be/?p=23</guid>
		<description><![CDATA[Here is a package containing functions to interact with delimited strings. the package is named STR and has to be placed in the SYS schema to be used anywhere in the database. Just compile it as sys then make a public synonym of it. Then you will be able to use functions this way: select [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a package containing functions to interact with delimited strings.</p>
<a class="downloadlink" href="http://bigjim-network.be/wp-content/plugins/download-monitor/download.php?id=1" title="Version0.5 téléchargé 277 fois" >Download STR package (277)</a>
<p>the package is named STR and has to be placed in the SYS schema to be used anywhere in the database. Just compile it as sys then make a public synonym of it. Then you will be able to use functions this way:</p>
<p>select str.&lt;thefunction&gt;(&lt;parameters&gt;) from dual;</p>
<p>Here is a couple of cool stuffs that could be realized with this package (for full details download the package)</p>
<p style="text-align: center;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Function will split a string.  The maximum size returnable<br />
is 4000 bytes and up to 15 fields.<br />
For Exammple:</p>
<p>SQL&gt; select str.split(&#8216;a,b,c,d&#8217;,3,&#8217;,') from dual;<br />
STR.SPLIT(&#8216;A,B,C,D&#8217;,3,&#8217;,')<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
c</p>
<p style="text-align: left;">select str.split(&#8216;a,b,c,d&#8217;,3,&#8217;,') from dual;<br />
@param in_del_field             string to be split<br />
@param in_position              position of split character(s) to return<br />
@param in_del                   delimter to split by<br />
@return Returns a single value from a string, up to 4K long</p>
<p><code>FUNCTION split<br />
(in_del_field  IN     VARCHAR2,<br />
in_pos        IN     NUMBER,<br />
in_del        IN     VARCHAR2)<br />
RETURN VARCHAR2;</code></p>
<p>Type is a collection/array of values returned from the split_array function</p>
<p>TYPE tab_split IS TABLE OF VARCHAR2(4000);</p>
<p style="text-align: center;">
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Funciton takes a string passed to it and returns it as a collection of the<br />
type tab_split.  For Example</p>
<p><code>DECLARE<br />
t_split str.tab_split := str.split_array('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',',');<br />
i       INTEGER;<br />
BEGIN<br />
FOR i IN t_split.FIRST .. t_split.LAST LOOP<br />
DBMS_OUTPUT.PUT_LINE(t_split(i));<br />
END LOOP;<br />
END;</code></p>
<p>@param in_del_field             string to be split<br />
@param in_del                   delimter to split by<br />
@return Returns an Array of type str.tab_split with a row for each delimited value in in_del_field.</p>
<p><code>FUNCTION split_array<br />
(in_del_field  IN     VARCHAR2,<br />
in_del        IN     VARCHAR2)<br />
RETURN tab_split;</code></p>
<p style="text-align: center;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Funciton takes a table of string passed to it and returns it as a delimited string.  For Example<br />
<code>DECLARE<br />
t_split str.tab_split := str.split_array('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',',');<br />
i       INTEGER;<br />
BEGIN<br />
FOR i IN t_split.FIRST .. t_split.LAST LOOP<br />
DBMS_OUTPUT.PUT_LINE(t_split(i));<br />
END LOOP;<br />
END;</code></p>
<p>@param in_tab                   table to unsplit<br />
@param in_del                   delimter to concat<br />
@return Returns an Varchar2 string delimited by the in_del var passed.</p>
<p><code>FUNCTION unsplit_array<br />
(in_tab  IN     tab_split,<br />
in_del        IN     VARCHAR2)<br />
RETURN VARCHAR2;</code></p>
<p style="text-align: center;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Function replace a string in a delimited string at the position passed in parameter.  For Example<br />
select str.replace_at_pos(&#8216;a,b,c,d,e,f,g,h,i&#8217;,2,&#8217;z',&#8217;,') from dual;<br />
/<br />
a,z,c,d,e,f,g,h,i<br />
@param in_del_field             delimited string<br />
@param in_pos                   position where to replace string<br />
@param in_text                  string to put in place at pos<br />
@param in_del                   delimter to split by<br />
@return Returns an Varchar2 string delimited by the in_del var passed.</p>
<p><code>FUNCTION replace_at_pos<br />
(in_del_field  IN     VARCHAR2,<br />
in_pos        IN     NUMBER,<br />
in_text       IN     VARCHAR2,<br />
in_del        IN     VARCHAR2)<br />
RETURN VARCHAR2;</code></p>
<p style="text-align: center;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Pipelined Function returns a table of one column with the deleminted string<br />
passed to it.  For example, you could do the following to return a table of<br />
the alphabet&#8230;</p>
<p><code>SELECT *<br />
FROM TABLE(str.split_pipe('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z',','))</code></p>
<p>@param in_del_field             string to be split<br />
@param in_del                   delimter to split by<br />
@return Returns a Piplined Table of Table Type tab_str with a row for each delimited value in in_del_field.<br />
<code>FUNCTION split_pipe<br />
(in_del_field  IN     VARCHAR2,<br />
in_del        IN     VARCHAR2)<br />
RETURN tab_str PIPELINED;</code></p>
<p>download the package <a class="downloadlink" href="http://bigjim-network.be/wp-content/plugins/download-monitor/download.php?id=1" title="Version0.5 téléchargé 277 fois" >Download STR package (277)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bigjim-network.be/2009/03/20/plsql-functions-for-delimited-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
