sql - 无法序列化临时记录类型postgres

标签 sql postgresql greenplum

我正在尝试根据以下某些标准使我的计算动态化,但是当我尝试将字段动态发送到我的计算逻辑时,它失败并显示错误“无法序列化 transient 记录类型”:

建表语句:

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 *,(1,2,calculation_logic) from calculation_t

注意:我使用的是 Greenplum 数据库。

最佳答案

尝试从您的查询中删除括号:

select *,1,2,calculation_logic from calculation_t

它对我有用。 谢谢,

关于sql - 无法序列化临时记录类型postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23136811/

相关文章:

mysql - 错误 #1242 更新时子查询返回多于 1 行

sql - AVG , group by, WHERE AVG greater (>) 问题

postgresql - 引发并捕获用户定义的异常

sql - Postgres : How to declare date datatype without timezone?

sql - 如何使用 SQL 窗口函数计算聚合的百分比

postgresql - 如何在postgresql8.2中将base64字符串转换为bytea

c# - 在 C# 中存储 SQL 结果

sql - 在 SQL Server 表 : which type should I choose? 中创建新的文本列

postgresql - Postgres 返回的行未通过非空检查

node.js - Postgresql 连接在 node.js 和 pg 中超时