错误:运算符不存在:位 = 整数

Mee*_*eem 4 postgresql variables bit assign

我需要将值 1 分配给类型为 bit 的变量。

示例

create or replace function test()
returns void as
$Body$
Declare
       var1 bit :=0;
Begin
       ....
       ....
       var1 := 1;
       ....
       ....
end;
$Body$
language plpgsql;
Run Code Online (Sandbox Code Playgroud)

错误

ERROR:  operator does not exist: bit = integer
Run Code Online (Sandbox Code Playgroud)

Kon*_*hov 5

您需要使用位字符串文字是这样的:var1 := B'1'。这里有更多关于位类型的例子