public inbox for [email protected]  
help / color / mirror / Atom feed
Error when following a documentation
2+ messages / 2 participants
[nested] [flat]

* Error when following a documentation
@ 2018-08-28 15:13 PG Doc comments form <[email protected]>
  2018-08-28 15:56 ` Re: Error when following a documentation David G. Johnston <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Doc comments form @ 2018-08-28 15:13 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/10/static/plpgsql-cursors.html
Description:

As specified On page
https://www.postgresql.org/docs/10/static/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING
i am trying to run below commands 
-------------------------------------------------
DECLARE
    key integer;
    curs4 CURSOR FOR SELECT * FROM tenk1 WHERE unique1 = key;
BEGIN
    key := 42;
    OPEN curs4;
--------------------------------------------------------
but i am getting below errors, please help
--------------------------------------------------------
postgres=# 
postgres=# SELECT VERSION();
                                                 version                    
            
                
-----------------------------------------------------------------------------------------
----------------
 PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7
20120313 (Red Hat 4.
4.7-18), 64-bit
(1 row)

postgres=# DECLARE
postgres-#     key integer;
ERROR:  syntax error at or near "integer"
LINE 2:     key integer;
                ^
postgres=#     curs4 CURSOR FOR SELECT * FROM tenk1 WHERE unique1 = key;
ERROR:  syntax error at or near "curs4"
LINE 1: curs4 CURSOR FOR SELECT * FROM tenk1 WHERE unique1 = key;
        ^
postgres=# BEGIN
postgres-#     key := 42;
ERROR:  syntax error at or near "key"
LINE 2:     key := 42;
            ^
postgres=#     OPEN curs4;
ERROR:  syntax error at or near "OPEN"
LINE 1: OPEN curs4;
        ^
postgres=# 

--------------------------------------------------------


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Error when following a documentation
  2018-08-28 15:13 Error when following a documentation PG Doc comments form <[email protected]>
@ 2018-08-28 15:56 ` David G. Johnston <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2018-08-28 15:56 UTC (permalink / raw)
  To: [email protected] <[email protected]>; [email protected] <[email protected]>

On Tuesday, August 28, 2018, PG Doc comments form <[email protected]>
wrote:

>
> postgres=# DECLARE
> postgres-#     key integer;
> ERROR:  syntax error at or near "integer"
> LINE 2:     key integer;
>                 ^
>

You are writing pl/psql language code at the SQL input prompt.  That won't
work.  You have to either use the SQL DO command or write a function.

David J.


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-08-28 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-28 15:13 Error when following a documentation PG Doc comments form <[email protected]>
2018-08-28 15:56 ` David G. Johnston <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox