你能告诉我为什么这个查询在 pgAdmin 中有效,但在使用 ODBC 的软件中无效:
CREATE TEMP TABLE temp296 WITH (OIDS) ON COMMIT DROP AS
SELECT age_group AS a,male AS m,mode AS t,AVG(speed) AS speed
FROM person JOIN info ON person.ppid=info.ppid
WHERE info.mode=2
GROUP BY age_group,male,mode;
SELECT age_group,male,mode,
CASE
WHEN age_group=1 AND male=0 THEN (info_dist_km/(SELECT avg_speed FROM temp296 WHERE a=1 AND m=0))*60
ELSE 0
END AS info_durn_min
FROM person JOIN info ON person.ppid=info.ppid
WHERE info.mode IN (7) AND info.info_dist_km>2;
我得到“42P01:错误:关系“temp296”不存在”。
我也尝试过“BEGIN; [...] COMMIT;” - “HY010:光标已打开”。
PostgreSQL 9.0.10,由 Visual C++ build 1500 编译,64 位 psqlODBC 09.01.0200 Windows 7 x64