Re: Error when selecting rows from a temporary table in ODBC - Mailing list pgsql-sql

From Tom Lane
Subject Re: Error when selecting rows from a temporary table in ODBC
Date
Msg-id 7349.985234300@sss.pgh.pa.us
Whole thread Raw
In response to Re: Error when selecting rows from a temporary table in ODBC  (Hiroshi Inoue <Inoue@tpf.co.jp>)
List pgsql-sql
Hiroshi Inoue <Inoue@tpf.co.jp> 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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Maybe a Bug, maybe bad SQL
Next
From: Tom Lane
Date:
Subject: Re: FULL JOIN