I am using Postgresql 9.3 and wrote a function as below:
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;
What I expect is that my id
variable will be assigned a number value example: 12502100
from the select to_number(...)
query.
However I got the below error
ERROR: syntax error at or near ":="
LINE 10: source :=(select code from buildings where name='I3')
How can I assign the query result (with some string operations) into the variable id?
I am also failed with Select Into id...
method.