2
我想根據以下某些條件使我的計算動態化,但是當我嘗試動態地將字段發送到我的計算邏輯時,它失敗,出現錯誤「Can not序列化瞬態記錄類型「:無法序列化瞬態記錄類型postgres
CREATE TABLE語句:
create table calculation_t(
Id serial,
product_id integer not null,
metric_id integer not null,
start_date date,
end_date date,
calculation_logic varchar(50),
insert_timestamp timestamp default current_timestamp,
CONSTRAINT calculation_pk PRIMARY KEY(Id),
CONSTRAINT calculation_pid_fk FOREIGN KEY(product_id) REFERENCES Product_T(Product_id),
CONSTRAINT calc_mid_fk FOREIGN KEY(metric_id) REFERENCES metric_T(metric_id)
);
Insert語句:
insert into calculation_t(product_id,metric_id,calculation_logic)
select a.product_id,b.metric_id,
(case when b.metric_id=2 then
('$1-$2') else
'$1/$2' end) calc
from product_t a,metric_t b
其拋出提到的錯誤SELECT語句:
select *,(1,2,calculation_logic) from calculation_t
注意:我正在使用Greenplum數據庫。
我不能用PostgreSQL 8.4或9.3重現你的錯誤。您確定要在SELECT語句中使用行構造函數嗎? –