<?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>Niccolo Favari - NFstudio &#187; PostgreSQL</title> <atom:link href="http://www.niccolofavari.com/categoria/postgresql/feed" rel="self" type="application/rss+xml" /><link>http://www.niccolofavari.com</link> <description>Development, Design and Communication on the Web</description> <lastBuildDate>Fri, 13 Aug 2010 14:11:56 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Get the PL/pgSQL language working in PostgreSQL</title><link>http://www.niccolofavari.com/get-the-plpgsql-language-working-in-postgresql</link> <comments>http://www.niccolofavari.com/get-the-plpgsql-language-working-in-postgresql#comments</comments> <pubDate>Wed, 20 Jan 2010 15:43:29 +0000</pubDate> <dc:creator>Niccolò Favari</dc:creator> <category><![CDATA[PostgreSQL]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[PL/pgSQL]]></category> <category><![CDATA[PostreSQL]]></category> <category><![CDATA[stored procedures]]></category> <category><![CDATA[triggers]]></category><guid isPermaLink="false">http://www.niccolofavari.com/?p=254</guid> <description><![CDATA[What to do if you get the "language "plpgsql" does not exist" error while working with stored procedures and triggers? <a href="http://www.niccolofavari.com/get-the-plpgsql-language-working-in-postgresql">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px;"> <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.niccolofavari.com%2Fget-the-plpgsql-language-working-in-postgresql"><br /> <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.niccolofavari.com%2Fget-the-plpgsql-language-working-in-postgresql&amp;source=NiccoloFavari&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br /> </a></div><p>I use the <a href="http://bitnami.org/stack/lappstack">Bitnami LAPPstack</a> on my Linux system to develop my apps. It&#8217;s fast, lightweight, and doesn&#8217;t get in the way messing up with my system. I start it, restart it, stop it&#8230; whenever I want.</p><p>One thing it doesn&#8217;t have, apart the XDebug extension (I wrote an article on how to get it working: <a href="http://www.niccolofavari.com/configure-xdebug-with-bitnami-php-stacks-on-linux-ubuntu">Configure XDebug with Bitnami PHP Stacks on Linux Ubuntu</a> ), is the <strong>PL/pgSQL language</strong> configured inside the postgresql DBMS. Meaning that if you try to create a stored procedure and a trigger using that language, you&#8217;re going to get an error similar to this:</p><div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">ERROR:  <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #ff0000;">&quot;plpgsql&quot;</span> does <span style="color: #993333; font-weight: bold;">NOT</span> exist</pre></div></div><p>To solve this issue, just fire up a terminal window and go inside the <code>postgresql/bin</code> folder of your lappstack installation (something like <code>/path/to/lappstack<strong>/postgresql/bin</strong></code>) and run this command:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createlang plpgsql <span style="color: #660033;">-h</span> localhost <span style="color: #660033;">-U</span> username databasename</pre></div></div><p><strong>Note:</strong> Change the host, the username and the databasename accordingly (the username being the username that you use to connect to the database).<br /> It will ask for a password (for that username) and then create the language. Done.</p><p>Now you can create stored procedures and triggers using the PL/pgSQL language.</p><p>I added <code><strong>-h localhost</strong></code> because I was getting the following error:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">could not connect to server: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
Is the server running locally and accepting
connections on Unix domain socket <span style="color: #ff0000;">&quot;/var/run/postgresql/.s.PGSQL.5432&quot;</span>?</pre></div></div><p>So if you&#8217;re getting something similar, try adding the correct host and the correct port:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createlang plpgsql <span style="color: #660033;">-h</span> localhost <span style="color: #660033;">-p</span> <span style="color: #000000;">5433</span> <span style="color: #660033;">-U</span> username databasename</pre></div></div><p>Hope it helps.</p> ]]></content:encoded> <wfw:commentRss>http://www.niccolofavari.com/get-the-plpgsql-language-working-in-postgresql/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 3/19 queries in 4.874 seconds using disk

Served from: www.niccolofavari.com @ 2010-09-09 02:45:35 -->