Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.3/8.11.1) with ESMTP id f2M4Bot74249 for ; Wed, 21 Mar 2001 23:11:50 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f2M4Be607352; Wed, 21 Mar 2001 23:11:40 -0500 (EST) To: Hiroshi Inoue cc: Ligia Pimentel , pgsql-sql@postgresql.org Subject: Re: Error when selecting rows from a temporary table in ODBC In-reply-to: <3AB95868.AD204C08@tpf.co.jp> References: <99ao69$25ul$1@news.tht.net> <3AB95868.AD204C08@tpf.co.jp> Comments: In-reply-to Hiroshi Inoue message dated "Thu, 22 Mar 2001 10:42:00 +0900" Date: Wed, 21 Mar 2001 23:11:40 -0500 Message-ID: <7349.985234300@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200103/434 X-Sequence-Number: 2102 Hiroshi Inoue writes: > Ligia Pimentel wrote: >> conn=57295424, query='drop table tmp_cr; drop table tmp_db; select >> sum(valor) as totalCR, count(correlativo) as docsCR, caja into tmp_cr from >> transaccion as t, codigocaja as c where c.codigo = t. codigo and c.tipomov = >> 'CR' group by caja; select sum(valor) as totalDB, count(correlativo) as >> docsDB, caja into tmp_db from transaccion t, codigocaja c where c.codigo = >> t. codigo and c.tipomov = 'DB' group by caja; select db.caja, totalcr, >> totaldb, docsdb, docscr from tmp_db db, tmp_cr cr where cr.caja = db.caja; ' > Seems a chained query is issued. > Queries in a chained query are parse and analyzed all > together before the chained query's execution. Therefore > SELECT couldn't see tables which didn't exist before > the execution. More to the point, the later SELECTs are probably being parsed with regard to the previous versions of tmp_cr and tmp_db that existed at the start of the line. This is fixed in 7.1, but in previous releases you'd best split up that sequence of operations into multiple query submissions. regards, tom lane