Skip site navigation (1) Skip section navigation (2)

A function to count number of terms - something wrong please help

From: Srinivas Iyyer <srini_iyyer_bio(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: A function to count number of terms - something wrong please help
Date: 2006-02-15 17:41:41
Message-ID: 20060215174141.92387.qmail@web34512.mail.mud.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
Dear group, 
 I wrote a function to return the number of records
that has this query term associated with. 

Something is going wrong. Looking forward some help to
correct this function. 
Could some one help if this function is correct way,
or please suggest other way please. 

Thanks
srini

SQL query and result:
test=# select distinct seq_name from sequence, go_seq,
gos where gos.go_term = 'protein binding' AND
gos.gos_id = go_seq.gos_id AND go_seq.seq_id =
sequence.seq_id ;
   seq_name
---------------
 A2M
 AATF
 ABCD1
 ABCD2
 ABCD3
.......
.......
 ZP3
 ZRANB1
 ZW10
 ZYX
(3862 rows)

===================================================
Function:
CREATE FUNCTION fetch_count_fterm(term) RETURNS char
AS '
DECLARE
        referrer_keys1 RECORD;
        fterm ALIAS FOR $1;
        mcounts integer;
BEGIN
        referrer_keys1 IN SELECT distinct seq_name
from sequence,go_seq,gos where gos.go_term = fterm AND
gos.gos_id = go_seq.gos_id AND go_seq.seq_id =
sequence.seq_id
       mcounts := select count(*) from referrer_keys1
        return mcounts;
END;
' LANGUAGE plpgsql;

test=# \i fetch_Fterm.sql
psql:fetch_Fterm.sql:11: ERROR:  type term does not
exist
test=#



Could some one help if this function is correct way,
or please suggest other way please. 

Thanks



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

In response to

Responses

pgsql-novice by date

Next:From: Sean DavisDate: 2006-02-15 17:47:41
Subject: Re: A function to count number of terms - something
Previous:From: Tom LaneDate: 2006-02-15 17:01:53
Subject: Re: Query does not return rows unless a LIMIT statement is used.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group