The Open Source Swiss Army Knife

/sql_servers/postgresql/pg_plpgsql/
/sql_servers/postgresql/pg_plpgsql/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /sql_servers   /postgresql   /pg_plpgsql 
Permalink: mazurek.sql
Title: add
article options : please login   |  raw source view  

drop function mazurek(integer);

CREATE FUNCTION mazurek (integer) RETURNS varchar AS '

DECLARE

      master_id_in alias for $1;
      master_count   integer;
      detail_count   integer;
   BEGIN
      SELECT into master_count count(*) FROM master;
      SELECT into detail_count count(*) FROM detail
         WHERE master_id_in=master_id;
      if master_count>detail_count
         then  RETURN  ''more references in master than in detail'';
      end if;
      if master_count<detail_count
         then  RETURN  ''less references in master than in detail'';
      end if;
      if master_count=detail_count
         then  RETURN  ''same amount of references'';
      end if;
        return rv;

END;
' LANGUAGE 'plpgsql' ;


Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top