我正在使用 Postgresql 9.3 并编写了如下函数:
create or replace function test(building text,floor text) returns void as $$
Declare
id integer;
num integer := 0;
Begin
num=num+100
id :=select to_number(
(select
(select code from buildings where name=building) || floor
|| (select num::text)),'99999999'
);
update table set col1=id;
End;
$$
language plpgsql;
我期望的是我的变量id
将被分配一个数字值example: 12502100
select to_number(...)
。
但是我收到以下错误
ERROR: syntax error at or near ":="
LINE 10: source :=(select code from buildings where name='I3')
如何将查询结果(带有一些字符串操作)分配给变量 id?
我的Select Into id...
方法也失败了。