Estou tentando fazer uma função onde o parametro "text" será o nome da
sequence o integer o select max da tabela onde eu quero pegar o valor
que sera atribuido a sequence.
Para executar ficaria assim:
select * from alt_seq('next_tabela',(select max(codigo) from tabela));
Quando e mando compilar a função aparece o sequinte erro:
ERROR: syntax error at or near "$1"
SQL state: 42601
Context: SQL statement in PL/PgSQL function "alt_seq" near line 7
Tem como eu alterar o valor da sequence com uma função ou procedure ?
CREATE OR REPLACE FUNCTION alt_seq(text, integer)
RETURNS boolean AS
$BODY$
DECLARE
v1 text := $1;
v2 integer := $2;
BEGIN
ALTER SEQUENCE v1 RESTART WITH v2;
RETURN TRUE;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION alt_seq(text, integer) OWNER TO postgres;
_______________________________________________
Grupo de Usuários do PostgreSQL no Brasil
Antes de perguntar consulte o manual
http://pgdocptbr.sourceforge.net/
Para editar suas opções ou sair da lista acesse a página da lista em:
http://pgfoundry.org/mailman/listinfo/brasil-usuarios