<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PostgreSQL: Determine if a column exists or not.</title>
	<atom:link href="http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/</link>
	<description>Ran-dumb ramblings of me...</description>
	<lastBuildDate>Tue, 28 Jun 2011 04:37:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: HungryTom</title>
		<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/comment-page-1/#comment-6684</link>
		<dc:creator>HungryTom</dc:creator>
		<pubDate>Thu, 11 Nov 2010 10:48:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/#comment-6684</guid>
		<description>Wicked! Cheers</description>
		<content:encoded><![CDATA[<p>Wicked! Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hoang_vn</title>
		<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/comment-page-1/#comment-5765</link>
		<dc:creator>Hoang_vn</dc:creator>
		<pubDate>Fri, 13 Aug 2010 08:29:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/#comment-5765</guid>
		<description>Thanks for this</description>
		<content:encoded><![CDATA[<p>Thanks for this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Mountain</title>
		<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/comment-page-1/#comment-4552</link>
		<dc:creator>David Mountain</dc:creator>
		<pubDate>Mon, 10 May 2010 15:00:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/#comment-4552</guid>
		<description>This creates a function to check if a column exists

-- check if a column exists
CREATE OR REPLACE FUNCTION column_exists(colname text, tablename text)
  RETURNS boolean AS
$BODY$
DECLARE

q text;
onerow record;

BEGIN
	q = &#039;SELECT attname FROM pg_attribute WHERE attrelid = ( SELECT oid FROM pg_class WHERE relname = &#039;&#039;&#039;&#124;&#124;tablename&#124;&#124;&#039;&#039;&#039;) AND attname = &#039;&#039;&#039;&#124;&#124;colname&#124;&#124;&#039;&#039;&#039; &#039;;
	FOR onerow IN EXECUTE q
	LOOP
		RETURN true;
	END LOOP;
	RETURN false;	
END;
$BODY$
  LANGUAGE &#039;plpgsql&#039; VOLATILE</description>
		<content:encoded><![CDATA[<p>This creates a function to check if a column exists</p>
<p>&#8211; check if a column exists<br />
CREATE OR REPLACE FUNCTION column_exists(colname text, tablename text)<br />
  RETURNS boolean AS<br />
$BODY$<br />
DECLARE</p>
<p>q text;<br />
onerow record;</p>
<p>BEGIN<br />
	q = &#8216;SELECT attname FROM pg_attribute WHERE attrelid = ( SELECT oid FROM pg_class WHERE relname = &#8221;&#8217;||tablename||&#8221;&#8217;) AND attname = &#8221;&#8217;||colname||&#8221;&#8217; &#8216;;<br />
	FOR onerow IN EXECUTE q<br />
	LOOP<br />
		RETURN true;<br />
	END LOOP;<br />
	RETURN false;<br />
END;<br />
$BODY$<br />
  LANGUAGE &#8216;plpgsql&#8217; VOLATILE</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Celessstino</title>
		<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/comment-page-1/#comment-4529</link>
		<dc:creator>Celessstino</dc:creator>
		<pubDate>Thu, 06 May 2010 19:34:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/#comment-4529</guid>
		<description>Useful, Thank you.</description>
		<content:encoded><![CDATA[<p>Useful, Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Another</title>
		<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/comment-page-1/#comment-2612</link>
		<dc:creator>Another</dc:creator>
		<pubDate>Thu, 05 Nov 2009 04:26:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/#comment-2612</guid>
		<description>Another thank you for taking the time to post this.</description>
		<content:encoded><![CDATA[<p>Another thank you for taking the time to post this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/comment-page-1/#comment-2140</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 31 Jul 2009 08:44:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.tequilafish.com/2007/02/23/postgresql-determine-if-a-column-exists-or-not/#comment-2140</guid>
		<description>Thanks for this :)</description>
		<content:encoded><![CDATA[<p>Thanks for this <img src='http://www.tequilafish.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

