Re: Where is the error?

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Where is the error?
Date: 2017-05-06 18:36:42
Message-ID: CA+FnnTzdP+V4FAshdyK8dA_zjLtZOLHcVi3QYKup4GsTxXBW=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, Christoph,

On May 6, 2017 2:24 PM, "Christoph Moench-Tegeder" <cmt(at)burggraben(dot)net>
wrote:

## Igor Korot (ikorot01(at)gmail(dot)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(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Devoy 2017-05-06 20:35:59 Any experiences with using PhpUnit's DbUnit extension with Postgres?
Previous Message Christoph Moench-Tegeder 2017-05-06 18:23:42 Re: Where is the error?