Re: [GENERAL] Where is the error?

2017-05-06 Thread Christoph Moench-Tegeder
## Igor Korot (ikoro...@gmail.com): > 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... Yes. In fact, "libpq Example Program 3" on https://www.postgresql.org/docs/current/static/libpq-example.

Re: [GENERAL] Where is the error?

2017-05-06 Thread Igor Korot
Hi, Christoph, On May 6, 2017 2:24 PM, "Christoph Moench-Tegeder" wrote: ## Igor Korot (ikoro...@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_

Re: [GENERAL] Where is the error?

2017-05-06 Thread Christoph Moench-Tegeder
## Igor Korot (ikoro...@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 "SEL

[GENERAL] Where is the error?

2017-05-06 Thread Igor Korot
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, quer

Re: [GENERAL] Where is the error

2004-12-27 Thread Kaloyan Iliev Iliev
Hi again, When I chage in the dump file CREATE FUNCTION int (boolean) RETURNS integer AS ' select CASE WHEN $1 THEN 1 ELSE 0 END ' LANGUAGE sql; ERROR: syntax error at or near "(" at character 21 I receive this message. So the question is how to create it without quotes. Thank in advance:) Kaloyan

Re: [GENERAL] Where is the error

2004-12-27 Thread Kaloyan Iliev Iliev
Thanks To you all. The problem was that the int was reserved. When I try CREATE FUNCTION my_int(boolean) RETURNS integer AS ' select CASE WHEN $1 THEN 1 ELSE 0 END ' LANGUAGE sql; it worked. But now I have to change it on many places. This is not good beacause on the old version of PG (form where

Re: [GENERAL] Where is the error

2004-12-27 Thread Andreas Kretschmer
begin Kaloyan Iliev Iliev <[EMAIL PROTECTED]> wrote: > Hi > I have the following function: > CREATE OR REPLACE FUNCTION "int" (boolean) RETURNS integer AS' I'm not sure. But 'int' is reserved, possibly is this the error. CREATE OR REPLACE FUNCTION my_int (boolean) RETURNS integer AS' select CA

Re: [GENERAL] Where is the error

2004-12-27 Thread Kaloyan Iliev Iliev
10x John, You are right.The problem is that the function was dumped with quotes from pg_dump but I suppose the one who created it used quotes and that's why it dumps in this way. I will fix this in the dump. Thanks again. Kaloyan John DeSoi wrote: On Dec 27, 2004, at 6:42 AM, Kaloyan Iliev I

Re: [GENERAL] Where is the error

2004-12-27 Thread Marek Lewczuk
Kaloyan Iliev Iliev napisaƅ(a): Hi I have the following function: select int('t'::bool); ERROR: syntax error at or near "(" at character 11 "int" is reserved for integer type, so you should not use it. However if you add namespace before function name "public.int(TRUE)" then it should work. ML

Re: [GENERAL] Where is the error

2004-12-27 Thread John DeSoi
On Dec 27, 2004, at 6:42 AM, Kaloyan Iliev Iliev wrote: CREATE OR REPLACE FUNCTION "int" (boolean) RETURNS integer AS' select CASE WHEN $1 THEN 1 ELSE 0 END 'LANGUAGE 'sql'; The problem is that you have quoted the function name as "int". You should only do this when you want to force the exact cas

[GENERAL] Where is the error

2004-12-27 Thread Kaloyan Iliev Iliev
Hi I have the following function: CREATE OR REPLACE FUNCTION "int" (boolean) RETURNS integer AS' select CASE WHEN $1 THEN 1 ELSE 0 END 'LANGUAGE 'sql'; When I try to use it: select int('t'::bool); ERROR: syntax error at or near "(" at character 11 I am using PG8.0b1 Thank you. Kaloyan -