pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brian Modra <brian@zwartberg.com>
To: Plugge, Joe R. <JRPlugge@west.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Function Syntax Help
Date: Fri, 30 Oct 2009 21:29:23 +0200
Message-ID: <5a9699850910301229r6e3b936g7c86d2ab0cdaa6c6@mail.gmail.com> (raw)
In-Reply-To: <BD69807DAE0CE44CA00A8338D0FDD083534BA92E@oma00cexmbx03.corp.westworlds.com>
References: <BD69807DAE0CE44CA00A8338D0FDD083534BA92E@oma00cexmbx03.corp.westworlds.com>

2009/10/30 Plugge, Joe R. <JRPlugge@west.com>

>  I am trying to create a function that will grind through a cdr table and
> populate another table.  I am trying to load the function and am getting the
> following error:
>
>
>
> ERROR:  function result type must be specified
>
>
>
>
>
> CREATE FUNCTION gen_simultaneous_calls(mystart timestamp, mystop timestamp)
> AS $$ DECLARE
>
>
you need to tell it the return type. If there is none, "returns void"

e.g.
 CREATE FUNCTION gen_simultaneous_calls(mystart timestamp, mystop timestamp)
returns void AS $$

>     mycount integer;
>
> BEGIN
>
>     WHILE mystart < mystop + INTERVAL '1 day' LOOP
>
>     SELECT INTO mycount  count(*) FROM log_calls WHERE startdate < mystart
> and enddate > mystop;
>
>     INSERT INTO simultaneous_calls_rpt (startdate,call_count) VALUES
> (mystart,mycount);
>
>     mystart := mystart + INTERVAL '1 minute';
>
>     mystop  := mystop + INTERVAL '1 minute';
>
>     END LOOP;
>
> END;
>
>     $$ LANGUAGE 'plpgsql' STABLE;
>
>
>
>
>
>
>
>
>
>
>
> [image: image001]*Joe R. Plugge*
>
> *Database Administrator, West Interactive Corporation*
>
> *11650 Miracle Hills Drive, Omaha NE 68154*
>
> *402-716-0349 | Cell 402-517-2710 | jrplugge@west.com** *
>
>
>
> *This electronic message transmission, including any attachments, contains
> information from West Corporation which may be confidential or privileged.
> The information is intended to be for the use of the individual or entity
> named above. If you are not the intended recipient, be aware that any
> disclosure, copying, distribution or use of the contents of this information
> is prohibited. *
>
> * *
>
> *If you have received this electronic transmission in error, please notify
> the sender immediately by a "reply to sender only" message and destroy all
> electronic and hard copies of the communication, including attachments.*
>



-- 
Brian Modra   Land line: +27 23 5411 462
Mobile: +27 79 69 77 082
5 Jan Louw Str, Prince Albert, 6930
Postal: P.O. Box 2, Prince Albert 6930
South Africa
http://www.zwartberg.com/

view thread (6+ messages)  latest in thread

Message-ID: <5a9699850910301229r6e3b936g7c86d2ab0cdaa6c6@mail.gmail.com>
Permalink:  ../5a9699850910301229r6e3b936g7c86d2ab0cdaa6c6@mail.gmail.com/
Also on:    postgresql.org/message-id/5a9699850910301229r6e3b936g7c86d2ab0cdaa6c6@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: brian@zwartberg.com, JRPlugge@west.com
  Subject: Re: Function Syntax Help
  In-Reply-To: <5a9699850910301229r6e3b936g7c86d2ab0cdaa6c6@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox