Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 0F9611337B3E for ; Wed, 24 Nov 2010 20:13:02 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 52570-03 for ; Thu, 25 Nov 2010 00:12:56 +0000 (UTC) X-Greylist: delayed 00:05:05.874913 by SQLgrey-1.7.6 Received: from newserver.jfcomputer.com (unknown [76.14.161.106]) by mail.postgresql.org (Postfix) with ESMTP id 86E281337B34 for ; Wed, 24 Nov 2010 20:12:54 -0400 (AST) Received: from localhost (unknown [127.0.0.1]) by newserver.jfcomputer.com (Postfix) with ESMTP id DA6965A5B for ; Wed, 24 Nov 2010 12:06:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at site Received: from newserver.jfcomputer.com ([127.0.0.1]) by localhost (linux-jfp8.site [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TVa4ZMDPZioJ for ; Wed, 24 Nov 2010 04:06:19 -0800 (PST) Received: from linux-desktop.localnet (unknown [76.14.161.106]) by newserver.jfcomputer.com (Postfix) with ESMTP id 39B5E10E0C for ; Wed, 24 Nov 2010 04:06:19 -0800 (PST) From: John Fabiani Organization: J.F. Computer Solutions To: pgsql-sql@postgresql.org Subject: insert from a select Date: Wed, 24 Nov 2010 16:07:43 -0800 User-Agent: KMail/1.13.5 (Linux/2.6.34.7-0.5-desktop; KDE/4.4.4; i686; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201011241607.43378.johnf@jfcomputer.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201011/55 X-Sequence-Number: 34793 Hi, I have a strange issue that is mostly likely me not understanding something. I always thought that an insert statement would accept any select statement. I'm guessing I am wrong. I have created a temporary table ("tempclass") that is exact match to an existing table ('esclass'). When I attempt to do the following insert into tempclass Select cl.pkid, cl.depart, cl.sessionid, cl.instrid, cl.classseq,(select facility from esloc where esloc.pkid = cl.locationid) as facility, cl.schedule from esclass cl where cl.pkid in (14507,14508) I get the following error: ERROR: column "schedule" is of type date but expression is of type character varying LINE 1: ... cl.depart, cl.sessionid, cl.instrid, cl.classseq,(select fa... ^ HINT: You will need to rewrite or cast the expression. The error makes no sense to me. But most important if I just run the select statement it works perfectly. Like I said the table "tempclass" (a temporary) is a dup of table "esclass" so none of it makes sense. Of course I did say I'm missing something. So why isn't the select statement working with the insert? Johnf