pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Travis Hoyt <thoyt@npc.net>
To: pgsql-sql@postgresql.org
Subject: Problems returning multiple columns
Date: Wed, 1 May 2002 12:51:29 -0400
Message-ID: <DBEMKMGOMJAGKAKEPPEGOEKCDOAA.thoyt@npc.net> (raw)

CREATE FUNCTION wklyavg(numeric, timestamp, timestamp) RETURNS TEXT AS '
         DECLARE
                 system          ALIAS FOR $1;
                 startdate       ALIAS FOR $2;
                 enddate         ALIAS FOR $3;
                 result          numeric;

         BEGIN
                 result := (select (avg(usr) + avg(sys)) from sardata
                        where systemid = system and time between startdate
and enddate);
                 return enddate || result;
         END;
' LANGUAGE 'plpgsql';

Above is the function I'm trying to run and I keep getting errors telling
me I need to cast my values.  I've played with it a bit but not knowing
much about casting I was hoping for some help.  I'm basically just summing
a couple of averages for values between two given dates.  I wanted to
return the summed average and the "enddate" as one row.  Any suggestions?

Thanks,

Travis

Attachments:

  smime.p7s (application/x-pkcs7-signature, 3.0K) download

Message-ID: <DBEMKMGOMJAGKAKEPPEGOEKCDOAA.thoyt@npc.net>
Permalink:  ../DBEMKMGOMJAGKAKEPPEGOEKCDOAA.thoyt@npc.net/
Also on:    postgresql.org/message-id/DBEMKMGOMJAGKAKEPPEGOEKCDOAA.thoyt@npc.net

 · 

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: thoyt@npc.net
  Subject: Re: Problems returning multiple columns
  In-Reply-To: <DBEMKMGOMJAGKAKEPPEGOEKCDOAA.thoyt@npc.net>

* 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