Re: PostgreSQL sequence within function
От | Russ Brown |
---|---|
Тема | Re: PostgreSQL sequence within function |
Дата | |
Msg-id | 42C4E3B6.50800@gmail.com обсуждение исходный текст |
Ответ на | Re: PostgreSQL sequence within function (Tony Caduto <tony_caduto@amsoftwaredesign.com>) |
Ответы |
Re: PostgreSQL sequence within function
|
Список | pgsql-general |
Tony Caduto wrote: > All you where really mising was a semi colon afer nextval('myseq') and > the begin end. > > CREATE or REPLACE FUNCTION getSeq() > RETURNS int AS > $$ > begin > RETURN nextval('myseq'); > end; > $$ > LANGUAGE 'plpgsql'; > > Clark Allan wrote: > This just made me think. If I was writing this function, I would have written it as an SQL function like this: CREATE or REPLACE FUNCTION getSeq() RETURNS int AS $$ SELECT nextval('myseq'); $$ LANGUAGE SQL; Does anybody know which version is actually better/faster/more optimal? I tend to always write functions as SQL where it's possible, as I imagine that an SQL database engine will be better at running an SQL functionion than an interpreted procedural function. Am I right to think that? -- Russ.
В списке pgsql-general по дате отправления: