From: | Igor Korot <ikorot01(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Where is the error? |
Date: | 2017-05-06 18:11:04 |
Message-ID: | CA+FnnTz0D1xZ7MS5fqPWWsPewwnb1pZDE9MNzzoK2dUO90AQGw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi, ALL,
I am trying to execute following piece of code:
[code]
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';";
res = PQexec( m_db, query1.c_str() );
if( PQresultStatus( res ) != PGRES_COMMAND_OK )
{
std::wstring err = m_pimpl->m_myconv.from_bytes(
PQerrorMessage( m_db ) );
errorMsg.push_back( err );
PQclear( res );
return 1;
}
[/code]
However running it gives an error in the query:
[quote]
RROR: syntax error at or near "SELECT"
LINE 1: DECLARE alltables CURSOR SELECT table_schema, table_name FRO...
^
[/quote]
The hat symbol is pointing to the "n" in the "table_name".
However trying to execute this query (without DECLARE part) inside
psql does not return any errors and runs fine.
What am I missing?
The code is written in C++ and compiled in C++11 mode with gcc 5 on
Gentoo Linux.
Thank you.
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Moench-Tegeder | 2017-05-06 18:23:42 | Re: Where is the error? |
Previous Message | Andres Freund | 2017-05-06 01:38:10 | Re: Logical decoding CPU-bound w/ large number of tables |