alter sequence in a function

From: Julio Leyva <jcleyva(at)hotmail(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: alter sequence in a function
Date: 2007-07-03 22:48:30
Message-ID: BAY120-W180EC0773E6E0BC38E448DA10C0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


Hi allI'm trying to create a function that alters a sequenceThis what I'm doingcreate or replace function updatesafe() returns integer AS $$DECLAREmaxseq integer;alterseq varchar(256);thumb integer;newvalue integer;BEGINnewvalue := 10010; maxseq := (select max(safeoperationid) from safeopencloseoperation); if (maxseq < 500) then return 3000; else execute 'ALTER sequence safeopencloseoperation_id_seq restart with ' || 'newvalue ' ; return 10000; END IF;END;$$ language plpgsqlIt compiles ok but when I call the functionit gives me this error ALTER sequence safeopencloseoperation_id_seq restart with newvalueCONTEXT: PL/pgSQL function "updatesafe" line 17 at execute statementLINE 1: ...equence safeopencloseoperation_id_seq restart with newvalueHowever when I change the alter sequence for thisALTER sequence safeopencloseoperation_id_seq restart with 10000 ;The function is ok,It means that we can't use such a utility inside a function? I mean replacing a value for a variable?Thanks for any suggestion

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message ngaleyev 2007-07-03 23:35:26 hot restart of posgtresql
Previous Message Namık Güngör 2007-07-03 19:32:28 (konusuz)