Search Postgresql Archives

Re: How to convert integer to string in functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In my table, some of the columns are in text datatype. Few data will come down from UI layer as integers. I want to convert that to string/text before saving it into the table. Please help me on this.


SQL Standard:  "CAST( value AS text )" [or varchar]
PostgreSQL short-hand:  "value::text"

In both formats replace value with whatever you want to convert.  When writing a parameterized  query (using ?) you can write "?::text" ( or Cast(? AS type) ) to explicitly cast the unknown parameter.  The "text" in the above can be any type name.

David J.





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux