Re: [GENERAL] Simple function

2009-12-23 Thread Christine Penner
Thanks a lot, that worked great. Saved me a lot of time trying to figure it out too. Christine It works for me: postgres=# CREATE OR REPLACE FUNCTION countertest(integer) RETURNS bigint AS $$ SELECT COUNT(*) FROM test WHERE nbr = $1; $$ LANGUAGE SQL; CREATE FUNCTION postgres=# select countert

Re: [GENERAL] Simple function

2009-12-23 Thread Richard Broersma
On Wed, Dec 23, 2009 at 9:03 AM, Christine Penner wrote: > Hi, > > I'm trying to create a simple function but having a bit of trouble. This is > what I want to do. > > I want to pass a key as a parameter (BKEY integer) > the code in the function should be > count(*) from F_BUILDINGS where B_PRIMAR

Re: [GENERAL] Simple function

2009-12-23 Thread Adrian Klaver
- "Christine Penner" wrote: > Hi, > > I'm trying to create a simple function but having a bit of trouble. > This is what I want to do. > > I want to pass a key as a parameter (BKEY integer) > the code in the function should be > count(*) from F_BUILDINGS where B_PRIMARY_SEQ=BKEY > > I

[GENERAL] Simple function

2009-12-23 Thread Christine Penner
Hi, I'm trying to create a simple function but having a bit of trouble. This is what I want to do. I want to pass a key as a parameter (BKEY integer) the code in the function should be count(*) from F_BUILDINGS where B_PRIMARY_SEQ=BKEY I want to return the count from the select statement. Ch

Re: [GENERAL] Simple function

2004-12-11 Thread Bruno Wolff III
On Tue, Dec 07, 2004 at 14:49:14 -0300, MaRCeLO PeReiRA <[EMAIL PROTECTED]> wrote: > Hi guys, > > I have a table with two integer fields (field1 and > field2)... > > I would like to construct a function that perform an > operation with this two fiels (field1 + fields2), and > return the string

[GENERAL] Simple function

2004-12-10 Thread MaRCeLO PeReiRA
Hi guys, I have a table with two integer fields (field1 and field2)... I would like to construct a function that perform an operation with this two fiels (field1 + fields2), and return the string value "A" if the sum is <20, "B" if the sum is >=20 or <=50, and finally return "C" if the sum is >50