Create function problem
Create function problem
От:
"Yaroslav Ulyanov" <yulyanov@mera.ru>
Дата:
Hello
I cannot write new function with local variables:
CREATE FUNCTION "get_new_id1" () RETURNS bigint AS'
declare
id bigint;
begin
id:=nextval(\'id_sequence\'::text);
return id;
end;
'LANGUAGE 'sql' VOLATILE ;
declare
id bigint;
begin
id:=nextval(\'id_sequence\'::text);
return id;
end;
'LANGUAGE 'sql' VOLATILE ;
Error message see when compiling:
ERROR: parser: parse error at or near "bigint" at character 16
That I do wrong?
pgAdmin3 - create function problem
От:
"Yaroslav Ulyanov" <yulyanov@mera.ru>
Дата:
HelloI cannot write new function with local variables:CREATE FUNCTION "get_new_id1" () RETURNS bigint AS'
declare
id bigint;
begin
id:=nextval(\'id_sequence\'::text);
return id;
end;
'LANGUAGE 'sql' VOLATILE ;Error message see when compiling:ERROR: parser: parse error at or near "bigint" at character 16That I do wrong?
pgAdmin
От:
"Yaroslav Ulyanov" <yulyanov@mera.ru>
Дата:
HelloI cannot write new function with local variables:CREATE FUNCTION "get_new_id1" () RETURNS bigint AS'
declare
id bigint;
begin
id:=nextval(\'id_sequence\'::text);
return id;
end;
'LANGUAGE 'sql' VOLATILE ;Error message see when compiling:ERROR: parser: parse error at or near "bigint" at character 16That I do wrong?
Re: Create function problem
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Yaroslav Ulyanov" writes: > CREATE FUNCTION "get_new_id1" () RETURNS bigint AS' > declare > id bigint; > begin > id:=3Dnextval(\'id_sequence\'::text); > return id; > end; > 'LANGUAGE 'sql' VOLATILE ; That's plpgsql code, but you've declared the function as language 'sql'. regards, tom lane