title: Postgres convert integer into text
body: <p>I have a question. I'm using a Postgrs database, and my problem is that I need to use the ints as text. I have the following solution:</p>
  
  <pre><code>CREATE FUNCTION pg_catalog.text(integer) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int4out($1));';
  
  CREATE CAST (integer AS text) WITH FUNCTION pg_catalog.text(integer) AS IMPLICIT;
  
  COMMENT ON FUNCTION pg_catalog.text(integer) IS 'convert integer to text';
  </code></pre>
  
  <p>I had been reading that this solution is not correct, it can cause some problems in the future. So I had been doing a research through the internet and I saw some people only use CAST, but just to convert a specific int, i.e., <a href="https://dba.stackexchange.com/questions/82511/how-to-enable-implicit-casts-in-postgresql-9-2">https://dba.stackexchange.com/questions/82511/how-to-enable-implicit-casts-in-postgresql-9-2</a></p>