cursor declare

From: Peter Koukoulis <pkoukoulis(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: cursor declare
Date: 2017-09-15 19:35:16
Message-ID: CABpxA9i-Qs8gnSjq4UEQDUUsYPiAxAzzfa2hwNBa1pCaFw3XSQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

This is my first cursor attempt:

according to docs

DECLARE
curs1 refcursor;
curs2 CURSOR FOR SELECT * FROM tenk1;
curs3 CURSOR (key integer) FOR SELECT * FROM tenk1 WHERE unique1 = key;

this should work, but getting error:

ft_node=# declare cur_test1 CURSOR (key integer) for select * from test1
where x=key;
ERROR: syntax error at or near "("
LINE 1: declare cur_test1 CURSOR (key integer) for select * from tes...

Table is defined as:
psql (9.6.4)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,
bits: 256, compression: off)
Type "help" for help.

ft_node=# \d+ test1
Table "public.test1"
Column | Type | Modifiers | Storage | Stats target |
Description
--------+-----------------------+-----------+----------+--------------+-------------
x | integer | | plain | |
y | character varying(20) | | extended | |

Can somebody please help?

P

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2017-09-15 19:39:24 Re: looking for a globally unique row ID
Previous Message Christopher Browne 2017-09-15 19:30:28 Re: looking for a globally unique row ID