【发布时间】:2013-10-09 08:43:17
【问题描述】:
我正在使用 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 变量将被分配一个来自select to_number(...) 查询的数字值example: 12502100。
但是我得到了以下错误
ERROR: syntax error at or near ":="
LINE 10: source :=(select code from buildings where name='I3')
如何将查询结果(带有一些字符串操作)赋值给变量id?
Select Into id... 方法我也失败了。
【问题讨论】:
标签: function postgresql variables