私は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...
方法で失敗しました。