-
Recent Posts
Tags
app engines attributes cgi database DBI Debian frameworks full screen terminal GWT hacks hardware hobbit howto html inheritance javascript jQuery libraries Linux mac oracle OSX parallels Perl photoshop pixels PostgreSQL programming qa regression testing screen size Software Development style template toolkit term Theory translation type cast User Interface virtual machine virtual machines visual studio vmware web design web programming
Simple Postgres Type Cast
I recently did a select similar to the following, where a subquery grabs some ids, and then a main query uses them:
But I got the following error:
The reason for this is that the sub-query ‘select id from documents…’ is returning text, but the attributes table is expecting an integer id. The two tables were created with the ids as ‘text’ in one and as ‘integers’ in the other. The way to fix this is to cast the text as integer in the sub-query by adding the text “::int” as follows:
See also:
http://www.depesz.com/index.php/2008/05/05/error-operator-does-not-exist-integer-text-how-to-fix-it/