<?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>Georgi.Budinov.com &#187; PostgreSQL</title>
	<atom:link href="http://georgi.budinov.com/category/databases/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://georgi.budinov.com</link>
	<description>The sacred mission of a Web Developer - Get the job done!</description>
	<lastBuildDate>Wed, 02 Nov 2011 13:55:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>PostgreSQL and network operators</title>
		<link>http://georgi.budinov.com/2011/02/postgresql-and-network-operators/</link>
		<comments>http://georgi.budinov.com/2011/02/postgresql-and-network-operators/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 12:37:38 +0000</pubDate>
		<dc:creator>Georgi Budinov</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[operator]]></category>

		<guid isPermaLink="false">http://georgi.budinov.com/?p=880</guid>
		<description><![CDATA[I am working on a couple of projects that require the use of PostgreSQL and I really like dealing with it. Full of features that are sometimes quite usefull. One of them is the &#60;&#60;= network operator. is contained within or equals &#8211; inet &#8217;192.168.1/24&#8242; &#60;&#60;= inet &#8217;192.168.1/24&#8242; This way one can check if an [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a couple of projects that require the use of PostgreSQL and I really like dealing with it. Full of features that are sometimes quite usefull. One of them is the &lt;&lt;= network operator.</p>
<p>is contained within or equals &#8211; inet &#8217;192.168.1/24&#8242; &lt;&lt;= inet &#8217;192.168.1/24&#8242;</p>
<p>This way one can check if an ip is in the range of a given network. Pretty simple, yeah! But I had the need to query ip address that are not in a specific network range <img src='http://georgi.budinov.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Well there is no opposite operator &#8211; at least I couldn&#8217;t find one. So what I did is is the following:</p>
<pre class="brush: php;">

SELECT COUNT(*) FROM ips WHERE  CASE WHEN ip &lt;&lt;= inet '192.168.1/24' THEN false ELSE true END
</pre>
<div class="social_bookmark"><script type="text/javascript"><!--
google_ad_client = "pub-1171831089941131";
google_ad_slot = "5499515740";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div><!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em>Bookmark It</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;title=PostgreSQL+and+network+operators" title="Bookmark 'PostgreSQL and network operators' in Del.icio.us"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Bookmark 'PostgreSQL and network operators' in Del.icio.us" alt="Bookmark 'PostgreSQL and network operators' in Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;title=PostgreSQL+and+network+operators" title="Bookmark 'PostgreSQL and network operators' in digg"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Bookmark 'PostgreSQL and network operators' in digg" alt="Bookmark 'PostgreSQL and network operators' in digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/" title="Bookmark 'PostgreSQL and network operators' in Technorati"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Bookmark 'PostgreSQL and network operators' in Technorati" alt="Bookmark 'PostgreSQL and network operators' in Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;t=PostgreSQL+and+network+operators" title="Bookmark 'PostgreSQL and network operators' in Yahoo My Web"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Bookmark 'PostgreSQL and network operators' in Yahoo My Web" alt="Bookmark 'PostgreSQL and network operators' in Yahoo My Web" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;title=PostgreSQL+and+network+operators" title="Bookmark 'PostgreSQL and network operators' in Google Bookmarks"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Bookmark 'PostgreSQL and network operators' in Google Bookmarks" alt="Bookmark 'PostgreSQL and network operators' in Google Bookmarks" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="https://favorites.live.com/quickadd.aspx?url=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;title=PostgreSQL+and+network+operators" title="Bookmark 'PostgreSQL and network operators' in Live-MSN"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/live.png" title="Bookmark 'PostgreSQL and network operators' in Live-MSN" alt="Bookmark 'PostgreSQL and network operators' in Live-MSN" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;t=PostgreSQL+and+network+operators" title="Bookmark 'PostgreSQL and network operators' in FaceBook"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Bookmark 'PostgreSQL and network operators' in FaceBook" alt="Bookmark 'PostgreSQL and network operators' in FaceBook" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=PostgreSQL+and+network+operators&amp;c=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/" title="Bookmark 'PostgreSQL and network operators' in MySpace"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/myspace.png" title="Bookmark 'PostgreSQL and network operators' in MySpace" alt="Bookmark 'PostgreSQL and network operators' in MySpace" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/" title="Bookmark 'PostgreSQL and network operators' in Twitter"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Bookmark 'PostgreSQL and network operators' in Twitter" alt="Bookmark 'PostgreSQL and network operators' in Twitter" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://friendfeed.com/share/bookmarklet/frame#title=PostgreSQL+and+network+operators&amp;url=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/" title="Bookmark 'PostgreSQL and network operators' in FriendFeed"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/friendfeed.png" title="Bookmark 'PostgreSQL and network operators' in FriendFeed" alt="Bookmark 'PostgreSQL and network operators' in FriendFeed" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/&amp;title=PostgreSQL+and+network+operators&amp;srcURL=http://georgi.budinov.com/2011/02/postgresql-and-network-operators/" title="Bookmark 'PostgreSQL and network operators' in Google Buzz"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Bookmark 'PostgreSQL and network operators' in Google Buzz" alt="Bookmark 'PostgreSQL and network operators' in Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://georgi.budinov.com/2011/02/postgresql-and-network-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a number of random generated unique strings into db</title>
		<link>http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/</link>
		<comments>http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 13:47:34 +0000</pubDate>
		<dc:creator>Georgi Budinov</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[unique]]></category>

		<guid isPermaLink="false">http://georgi.budinov.com/?p=862</guid>
		<description><![CDATA[Today I accidentally got to a piece of code I have written long ago and really got surprised from me. I have created a not conventional solution to a interesting problem. Imagine you have to add a bunch of rows into a db table, for example promo codes, that has column holding randomly generated strings. [...]]]></description>
			<content:encoded><![CDATA[<p>Today I accidentally got to a piece of code I have written long ago and really got surprised from me. I have created a not conventional solution to a interesting problem. Imagine you have to add a bunch of rows into a db table, for example promo codes, that has column holding randomly generated strings. The strings should be unique of course, so we have unique key in the db! So instead of generating the string, checking if it is already in the table and if not -&gt; adding it to the table, I have just written this:</p>
<pre class="brush: php;">
$j = 0;
for($i=0; $i&lt;$count; $i++)
{
	while(true)
	{
		try
		{
			$code = str_makerand();
			$codeID = $this-&gt;addItem(
				$this-&gt;tableNameCodes,
				array('code'),
				array($code)
			);

			break;
		}
		catch(Exception $e){
			$j++;
			if($j=10) break;
		}
	}
}
</pre>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em>Bookmark It</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;title=Adding+a+number+of+random+generated+unique+strings+into+db" title="Bookmark 'Adding a number of random generated unique strings into db' in Del.icio.us"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Del.icio.us" alt="Bookmark 'Adding a number of random generated unique strings into db' in Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;title=Adding+a+number+of+random+generated+unique+strings+into+db" title="Bookmark 'Adding a number of random generated unique strings into db' in digg"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Bookmark 'Adding a number of random generated unique strings into db' in digg" alt="Bookmark 'Adding a number of random generated unique strings into db' in digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/" title="Bookmark 'Adding a number of random generated unique strings into db' in Technorati"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Technorati" alt="Bookmark 'Adding a number of random generated unique strings into db' in Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;t=Adding+a+number+of+random+generated+unique+strings+into+db" title="Bookmark 'Adding a number of random generated unique strings into db' in Yahoo My Web"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Yahoo My Web" alt="Bookmark 'Adding a number of random generated unique strings into db' in Yahoo My Web" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;title=Adding+a+number+of+random+generated+unique+strings+into+db" title="Bookmark 'Adding a number of random generated unique strings into db' in Google Bookmarks"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Google Bookmarks" alt="Bookmark 'Adding a number of random generated unique strings into db' in Google Bookmarks" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="https://favorites.live.com/quickadd.aspx?url=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;title=Adding+a+number+of+random+generated+unique+strings+into+db" title="Bookmark 'Adding a number of random generated unique strings into db' in Live-MSN"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/live.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Live-MSN" alt="Bookmark 'Adding a number of random generated unique strings into db' in Live-MSN" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;t=Adding+a+number+of+random+generated+unique+strings+into+db" title="Bookmark 'Adding a number of random generated unique strings into db' in FaceBook"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Bookmark 'Adding a number of random generated unique strings into db' in FaceBook" alt="Bookmark 'Adding a number of random generated unique strings into db' in FaceBook" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=Adding+a+number+of+random+generated+unique+strings+into+db&amp;c=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/" title="Bookmark 'Adding a number of random generated unique strings into db' in MySpace"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/myspace.png" title="Bookmark 'Adding a number of random generated unique strings into db' in MySpace" alt="Bookmark 'Adding a number of random generated unique strings into db' in MySpace" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/" title="Bookmark 'Adding a number of random generated unique strings into db' in Twitter"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Twitter" alt="Bookmark 'Adding a number of random generated unique strings into db' in Twitter" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://friendfeed.com/share/bookmarklet/frame#title=Adding+a+number+of+random+generated+unique+strings+into+db&amp;url=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/" title="Bookmark 'Adding a number of random generated unique strings into db' in FriendFeed"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/friendfeed.png" title="Bookmark 'Adding a number of random generated unique strings into db' in FriendFeed" alt="Bookmark 'Adding a number of random generated unique strings into db' in FriendFeed" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/&amp;title=Adding+a+number+of+random+generated+unique+strings+into+db&amp;srcURL=http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/" title="Bookmark 'Adding a number of random generated unique strings into db' in Google Buzz"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Bookmark 'Adding a number of random generated unique strings into db' in Google Buzz" alt="Bookmark 'Adding a number of random generated unique strings into db' in Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://georgi.budinov.com/2011/01/adding-a-number-of-random-generated-unique-strings-into-db/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

