<?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>Jonathan Echeverría - Lo que tengo en la cabeza &#187; migraciones postgres</title>
	<atom:link href="http://www.jonathanecheverria.com/tag/migraciones-postgres/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jonathanecheverria.com</link>
	<description>Documentos técnicos, soluciones a problemas, cuaderno de bitácora, fotografías...</description>
	<lastBuildDate>Wed, 31 Aug 2011 17:50:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>SQL para hacer cast de postgres 8.2 para postgres 8.3</title>
		<link>http://www.jonathanecheverria.com/2008/08/28/sql-para-hacer-cast-de-postgres-82-para</link>
		<comments>http://www.jonathanecheverria.com/2008/08/28/sql-para-hacer-cast-de-postgres-82-para#comments</comments>
		<pubDate>Thu, 28 Aug 2008 11:41:00 +0000</pubDate>
		<dc:creator>Jonathan Echeverria</dc:creator>
				<category><![CDATA[SQL-Bases Datos]]></category>
		<category><![CDATA[casting postgresql 8.3]]></category>
		<category><![CDATA[funciones en postgresql 8.3]]></category>
		<category><![CDATA[migraciones postgres]]></category>
		<category><![CDATA[migrar postgresql 8.2 a 8.3]]></category>

		<guid isPermaLink="false">http://www.jonathanecheverria.com/2008/08/28/sql-para-hacer-cast-de-postgres-82-para/</guid>
		<description><![CDATA[Cuando se realiza la migración de postgres 8.2 a postgres 8.3, no todos los tipos de datos son iguales, y es necesario hacer unos cast de tipo, y de funciones para que todo funcione correctamente. Para ello basta con ejecutar las siguientes sentencias SQL: CREATE FUNCTION pg_catalog.text&#40;INTEGER&#41; RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>Cuando se realiza la migración de postgres 8.2 a postgres 8.3, no todos los tipos de datos son iguales, y es necesario hacer unos cast de tipo, y de funciones para que todo funcione correctamente. Para ello basta con ejecutar las siguientes sentencias SQL:</p>
<p><span id="more-25"></span></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">INTEGER</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(int4out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">INTEGER</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SMALLINT</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(int2out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SMALLINT</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SMALLINT</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span>oid<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(oidout($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span>oid <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span>oid<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(date_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">DATE</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">DOUBLE</span> <span style="color: #993333; font-weight: bold;">PRECISION</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(float8out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">DOUBLE</span> <span style="color: #993333; font-weight: bold;">PRECISION</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">DOUBLE</span> <span style="color: #993333; font-weight: bold;">PRECISION</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REAL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(float4out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REAL</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REAL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIME</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(timetz_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIME</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIME</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIME</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(time_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIME</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIME</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(timestamptz_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">INTERVAL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(interval_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">INTERVAL</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">INTERVAL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">BIGINT</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(int8out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">BIGINT</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">BIGINT</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NUMERIC</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(numeric_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NUMERIC</span> <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NUMERIC</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">RETURNS</span> text STRICT IMMUTABLE <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #993333; font-weight: bold;">SQL</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'SELECT textin(timestamp_out($1));'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">CAST</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone <span style="color: #993333; font-weight: bold;">AS</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> pg_catalog<span style="color: #66cc66;">.</span>text<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> IMPLICIT;</pre></div></div>

<h3  class="related_post_title">Artículos relacionados:</h3><ul class="related_post"><li>23 de octubre, 2009 -- <a href="http://www.jonathanecheverria.com/2009/10/23/obtener-lista-de-tablas-en-postgresql" title="Obtener lista de tablas en postgresql">Obtener lista de tablas en postgresql</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanecheverria.com/2008/08/28/sql-para-hacer-cast-de-postgres-82-para/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

