我想使用concat函式或||運算子將文本資料插入Postgres bytea列中。我得到了一個錯誤
column "name" is of type bytea but expression is of type text
create table test(
name bytea
);
insert into test(name) values(concat('abac-' , 'test123')) 。
insert into test(name) values('aa' || 'bb') 。
我正在一個存盤程序中執行插入操作。如果要添加引數,如
(concat('abac-' , row.name , 'test123')) 。
我怎么做?
我怎么做?
uj5u.com熱心網友回復:
在連接這些值之后執行型別轉換:
INSERT INTO test (name)
VALUES (CAST('abac-' || 行。 name || 'test123' AS bytea))。)
注意:||和concat之間的區別是它們如何處理NULL。
uj5u.com熱心網友回復:
你需要將兩個字串都投給bytea,例如:
insert into test(name) values('aa'/span>: :bytea || 'bb'::bytea)。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/332500.html
標籤:
