-<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.107 2007/04/16 17:21:22 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.108 2007/04/28 23:54:58 neilc Exp $ -->
<chapter id="plpgsql">
<title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
<title><literal>FETCH</></title>
<synopsis>
-FETCH <optional> <replaceable>direction</replaceable> FROM </optional> <replaceable>cursor</replaceable> INTO <replaceable>target</replaceable>;
+FETCH <optional> <replaceable>direction</replaceable> { FROM | IN } </optional> <replaceable>cursor</replaceable> INTO <replaceable>target</replaceable>;
</synopsis>
<para>
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.100 2007/04/16 17:21:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.101 2007/04/28 23:54:59 neilc Exp $
*
*-------------------------------------------------------------------------
*/
else if (pg_strcasecmp(yytext, "absolute") == 0)
{
fetch->direction = FETCH_ABSOLUTE;
- fetch->expr = plpgsql_read_expression(K_FROM, "FROM");
+ fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM or IN",
+ "SELECT ", true, true, NULL);
check_FROM = false;
}
else if (pg_strcasecmp(yytext, "relative") == 0)
{
fetch->direction = FETCH_RELATIVE;
- fetch->expr = plpgsql_read_expression(K_FROM, "FROM");
+ fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM or IN",
+ "SELECT ", true, true, NULL);
check_FROM = false;
}
else if (pg_strcasecmp(yytext, "forward") == 0)
{
fetch->direction = FETCH_BACKWARD;
}
+ else if (tok != T_SCALAR)
+ {
+ plpgsql_push_back_token(tok);
+ fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM or IN",
+ "SELECT ", true, true, NULL);
+ check_FROM = false;
+ }
else
{
/* Assume there's no direction clause */
check_FROM = false;
}
- /* check FROM keyword after direction's specification */
- if (check_FROM && yylex() != K_FROM)
- yyerror("expected \"FROM\"");
+ /* check FROM or IN keyword after direction's specification */
+ if (check_FROM)
+ {
+ tok = yylex();
+ if (tok != K_FROM && tok != K_IN)
+ yyerror("expected FROM or IN");
+ }
return fetch;
}