【发布时间】:2013-05-31 03:51:33
【问题描述】:
我试过这个查询。
SELECT * FROM(
SELECT DISTINCT ('Kegiatan - ' || coalesce(e.nama,'')) caption, l.id_event id,'e'::text AS berita_type
FROM event e
LEFT JOIN lokasi_pengamatan l ON l.id_event=e.id_event
LEFT JOIN users_location u ON l.id_lokasi_pengamatan=u.id_lokasi_pengamatan
WHERE
1=1
AND l.status = TRUE
AND e.status = TRUE
AND e.e_deleted_at IS NULL
AND l.lp_deleted_at IS NULL
)t1
UNION ALL
SELECT * FROM(
SELECT DISTINCT coalesce(e.nama,'') || ' - ' || coalesce(l.nama,'') caption, l.id_lokasi_pengamatan id, 'lp'::text AS berita_type
FROM event e
LEFT JOIN lokasi_pengamatan l ON l.id_event=e.id_event
LEFT JOIN users_location u ON l.id_lokasi_pengamatan=u.id_lokasi_pengamatan
WHERE
1=1
AND l.status = TRUE
AND e.status = TRUE
AND e.e_deleted_at IS NULL
AND l.lp_deleted_at IS NULL
)t2
ORDER BY berita_type ASC, id DESC, caption ASC
当通过 Postgre Manager 执行时查询正常,但在通过 CDbCommand 执行时引发错误。
SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block. The SQL statement executed was:
有人知道为什么吗?
【问题讨论】:
-
我从未听说过“Postgre 管理器”。你是说 PgAdmin-III 吗?无论如何,问题不在于那个查询,而是您在它之前运行的一些查询导致了错误。谷歌错误消息以了解我的意思。
-
@CraigRinger 就是其中之一,或者
Navicat -
@CraigRinger Yap,错误是由之前的查询引起的。
标签: sql postgresql activerecord yii postgresql-8.4