Thread: PL/PG SQL: select count(*) into from where - does not compute the where cond

PL/PG SQL: select count(*) into from where - does not compute the where cond

From
"Abraham, Danny"
Date:
Instead it returns the full count of the table.

Any idea?

Thanks

Danny Abraham
BMC Software
CTM&D Business Unit
972-52-4286-513
danny_abraham@bmc.com


Re: PL/PG SQL: select count(*) into from where - does not compute the where cond

From
Pavel Stehule
Date:
Hello

try to check if there are some column names are equal to variable names.

This is symptom of identifier collision.

regards
Pavel Stehule

2009/9/23 Abraham, Danny <danny_abraham@bmc.com>:
> Instead it returns the full count of the table.
>
> Any idea?
>
> Thanks
>
> Danny Abraham
> BMC Software
> CTM&D Business Unit
> 972-52-4286-513
> danny_abraham@bmc.com
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Re: PL/PG SQL: select count(*) into from where - does not compute the where cond

From
"A. Kretschmer"
Date:
In response to Abraham, Danny :
> Instead it returns the full count of the table.
>
> Any idea?

No. Can you show us an example?

test=*# select * from o;
 i
---
 3
 1
 2
(3 rows)

test=*# create or replace function my_count() returns int as $$declare c int;begin select into c count(1) from o where
i=2;return c; end;$$language plpgsql; 
CREATE FUNCTION
test=*# select * from my_count();
 my_count
----------
        1
(1 row)

In other words: works for me.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)

Re: PL/PG SQL: select count(*) into from where - does not compute the where cond

From
Pavel Stehule
Date:
Hello

try to check if there are some column names are equal to variable names.

 This is symptom of identifier collision.

regards

Pavel Stehule

>
> 2009/9/23 Abraham, Danny <danny_abraham@bmc.com>:
>> Instead it returns the full count of the table.
>>
>> Any idea?
>>
>> Thanks
>>
>> Danny Abraham
>> BMC Software
>> CTM&D Business Unit
>> 972-52-4286-513
>> danny_abraham@bmc.com
>>
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>>
>