<?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"
	>

<channel>
	<title>coding.sergey &#187; recipes</title>
	<atom:link href="http://coding.sergey.me/category/recipes/feed/" rel="self" type="application/rss+xml" />
	<link>http://coding.sergey.me</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Tue, 02 Mar 2010 21:52:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>inet_ntoa and inet_aton functions for Postgresql</title>
		<link>http://coding.sergey.me/2009/03/31/inet_ntoa-and-inet_aton-functions-for-postgresql/</link>
		<comments>http://coding.sergey.me/2009/03/31/inet_ntoa-and-inet_aton-functions-for-postgresql/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 14:18:43 +0000</pubDate>
		<dc:creator>sergey</dc:creator>
		
		<category><![CDATA[recipes]]></category>

		<category><![CDATA[postgresql]]></category>

		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://coding.sergey.me/?p=7</guid>
		<description><![CDATA[These functions can be used to convert integer to ip and visa verse. This sometimes also called inet_itoa and inet_atoi.

create or replace function inet_aton(inet) returns bigint as '
select inetmi($1,''0.0.0.0'');'
language sql immutable;
create or replace function inet_ntoa(int) returns inet as '
select ''0.0.0.0''::inet+$1;'
language sql immutable;
=&#62; select inet_ntoa(16843265);
inet_itoa
&#8212;&#8212;&#8212;&#8211;
1.1.2.1
(1 row)
=&#62; select inet_aton(&#8217;1.1.2.1&#8242;);
inet_atoi
&#8212;&#8212;&#8212;&#8211;
16843265
(1 row)
]]></description>
			<content:encoded><![CDATA[<p>These functions can be used to convert integer to ip and visa verse. This sometimes also called inet_itoa and inet_atoi.</p>
<p><code><br />
create or replace function inet_aton(inet) returns bigint as '<br />
select inetmi($1,''0.0.0.0'');'<br />
language sql immutable;<br />
create or replace function inet_ntoa(int) returns inet as '<br />
select ''0.0.0.0''::inet+$1;'<br />
language sql immutable;</code></p>
<p>=&gt; select inet_ntoa(16843265);<br />
inet_itoa<br />
&#8212;&#8212;&#8212;&#8211;<br />
1.1.2.1<br />
(1 row)</p>
<p>=&gt; select inet_aton(&#8217;1.1.2.1&#8242;);<br />
inet_atoi<br />
&#8212;&#8212;&#8212;&#8211;<br />
16843265<br />
(1 row)</p>
]]></content:encoded>
			<wfw:commentRss>http://coding.sergey.me/2009/03/31/inet_ntoa-and-inet_aton-functions-for-postgresql/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
