Обсуждение: Create function problem

Поиск
Список
Период
Сортировка

Create function problem

От
"Yaroslav Ulyanov"
Дата:
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 ;
 
 
Error message see when compiling:
 
ERROR:  parser: parse error at or near "bigint" at character 16
 
 
That I do wrong?
 
 
Best regards,
Yaroslav Ulyanov
yulyanov@mera.ru

pgAdmin3 - create function problem

От
"Yaroslav Ulyanov"
Дата:
 

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 ;
 
 
Error message see when compiling:
 
ERROR:  parser: parse error at or near "bigint" at character 16
 
 
That I do wrong?
 
 
Best regards,
Yaroslav Ulyanov
yulyanov@mera.ru

pgAdmin

От
"Yaroslav Ulyanov"
Дата:
 

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 ;
 
 
Error message see when compiling:
 
ERROR:  parser: parse error at or near "bigint" at character 16
 
 
That I do wrong?
 
 
Best regards,
Yaroslav Ulyanov
yulyanov@mera.ru

Re: Create function problem

От
Tom Lane
Дата:
"Yaroslav Ulyanov" <yulyanov@mera.ru> 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