Re: [GENERAL] Where is the error? - Mailing list pgsql-general

From Igor Korot
Subject Re: [GENERAL] Where is the error?
Date
Msg-id CA+FnnTzdP+V4FAshdyK8dA_zjLtZOLHcVi3QYKup4GsTxXBW=A@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Where is the error?  (Igor Korot <ikorot01@gmail.com>)
Responses Re: [GENERAL] Where is the error?  (Christoph Moench-Tegeder <cmt@burggraben.net>)
List pgsql-general
Hi, Christoph,



On May 6, 2017 2:24 PM, "Christoph Moench-Tegeder" <cmt@burggraben.net> wrote:
## Igor Korot (ikorot01@gmail.com):

>     std::string query1 = "DECLARE alltables CURSOR SELECT
> table_schema, table_name FROM information_schema.tables WHERE
> table_type = 'BASE TABLE' OR table_type = 'VIEW' OR table_type =
> 'LOCAL TEMPORARY';";

> [quote]
> RROR:  syntax error at or near "SELECT"
> LINE 1: DECLARE alltables CURSOR SELECT table_schema, table_name FRO...

> What am I missing?

A "FOR" in front of the "SELECT":
https://www.postgresql.org/docs/current/static/sql-declare.html

Another question - do I have to do "DECLARE CURSOR..." or I can just write a normal SELECT query?
For this I followed and example on the libpg page...

Thank you.



Note you can use cursors via psql, too - only they have to be in a
transaction block (but postgres will tell you, once you got the
syntax right).

Regards,
Christoph

--
Spare Space


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Christoph Moench-Tegeder
Date:
Subject: Re: [GENERAL] Where is the error?
Next
From: Peter Devoy
Date:
Subject: [GENERAL] Any experiences with using PhpUnit's DbUnit extension with Postgres?