小编Kum*_*put的帖子

在postgresql中连接两个int值

我有7个整数值(分别有3,1,3,4,4,5,4位),我必须将它们连接成一个整数(即24位数字).我试着这样做

create or replace function gen_id(int,int,int,int,int,int,int) returns bigint as $$
declare
    id bigint;
begin
    id = $1 * 1000000000000000000000 + $2 * 100000000000000000000 + $3 * 100000000000000000 + $4 * 10000000000000 + $5 * 1000000000 + $6 * 10000 + $7;
    return id;
end;
$$ language plpgsql;

select * from gen_id(100,1,101,1000,1001,10001,1000);  
Run Code Online (Sandbox Code Playgroud)

但是当我执行它时,我得到错误:bigint超出范围.还有其他更好的方法吗?
谢谢

postgresql integer concatenation

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

concatenation ×1

integer ×1

postgresql ×1