Sql Can';t序列化临时记录类型postgres
我试图根据以下某些条件使计算动态化,但当我尝试将字段动态发送到我的计算逻辑时,它失败,错误为“无法序列化瞬态记录类型”: Create table语句:Sql Can';t序列化临时记录类型postgres,sql,postgresql,greenplum,Sql,Postgresql,Greenplum,我试图根据以下某些条件使计算动态化,但当我尝试将字段动态发送到我的计算逻辑时,它失败,错误为“无法序列化瞬态记录类型”: 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 var
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 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
插入语句:
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 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数据库。尝试从查询中删除括号:
select *,1,2,calculation_logic from calculation_t
这对我有用。
Thanx,我无法用PostgreSQL 8.4或9.3重现您的错误。确实要在SELECT语句中使用行构造函数吗?