Re: Parameters don't work in FETCH NEXT clause?

Поиск
Список
Период
Сортировка
От Shay Rojansky
Тема Re: Parameters don't work in FETCH NEXT clause?
Дата
Msg-id CADT4RqBsC1YsX2ByQCDAfRNYFDU=+uBvxxL1X9=+B6=M6es8Rw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Parameters don't work in FETCH NEXT clause?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Parameters don't work in FETCH NEXT clause?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
<div dir="ltr">Apologies, as usual I didn't read the docs carefully enough.</div><div class="gmail_extra"><br /><div
class="gmail_quote">OnTue, May 17, 2016 at 7:13 PM, Tom Lane <span dir="ltr"><<a href="mailto:tgl@sss.pgh.pa.us"
target="_blank">tgl@sss.pgh.pa.us</a>></span>wrote:<br /><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px#ccc solid;padding-left:1ex">Shay Rojansky <<a href="mailto:roji@roji.org">roji@roji.org</a>>
writes:<br/> > A user of mine just raised a strange issue... While it is possible to use a<br /> > parameter in a
LIMITclause, PostgreSQL does not seem to allow using one in<br /> > a FETCH NEXT clause. In other words, while the
followingworks:<br /> > SELECT 1 LIMIT $1;<br /> > The following generates a syntax error:<br /> > SELECT 1
FETCHNEXT $1 ROWS ONLY;<br /> > Since LIMIT and FETCH NEXT are supposed to be equivalent this behavior is<br /> >
odd.<br/><br /> Per the SELECT reference page:<br /><br />     SQL:2008 introduced a different syntax to achieve the
sameresult,<br />     which PostgreSQL also supports. It is:<br /><br />         OFFSET start { ROW | ROWS }<br />    
   FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY<br /><br />     In this syntax, to write anything except a
simpleinteger constant for<br />     start or count, you must write parentheses around it.<br /><br /> The comments
aboutthis in gram.y are informative:<br /><br />  * Allowing full expressions without parentheses causes various
parsing<br/>  * problems with the trailing ROW/ROWS key words.  SQL only calls for<br />  * constants, so we allow the
restonly with parentheses.  If omitted,<br />  * default to 1.<br /><br />                         regards, tom lane<br
/></blockquote></div><br/></div> 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Parameters don't work in FETCH NEXT clause?
Следующее
От: Jaime Casanova
Дата:
Сообщение: Re: 10.0