pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Rhaoni Chiu Pereira <rhaoni@sistemica.info>
Cc: pgsql-admin@postgresql.org
Subject: Re: Problems creating a function
Date: Tue, 19 Aug 2003 09:20:09 -0700 (PDT)
Message-ID: <20030819091906.S67349-100000@megazone.bigpanda.com> (raw)
In-Reply-To: <1061309605.3f424ca5e30ee@sistemica.info>


On Tue, 19 Aug 2003, Rhaoni Chiu Pereira wrote:

> Hi List,
>
>
>    I was wondering if someone could help me out. I'm migrating a Oracle db to
> PostgreSQL so I must rewrite the functions 'cuz the PL/pgSQL's sintax is
> different. The problem is to sum dates .. as follows:
>
> CREATE FUNCTION ft_vcto_dupl(NUMERIC,NUMERIC,TIMESTAMP,NUMERIC,TIMESTAMP)
> RETURNS TIMESTAMP AS '
>    DECLARE
>    pEmp ALIAS FOR $1;
>    pFil ALIAS FOR $2;
>    pDataEmissao ALIAS FOR $3;
>    pCodigoPrazoPgto ALIAS FOR $4;
>    pPrazoPgtoFixo ALIAS FOR $5;
>    mDataVctoDupl TIMESTAMP := pPrazoPgtoFixo;
>    mPrazoPgto NUMERIC(3) := 0;
>    BEGIN
>      SELECT INTO mPrazoPgto prazo FROM ftpraz00 WHERE emp = pEmp AND fil = 0
> AND codigo = pCodigoPrazoPgto;
>      IF NVL(to_number(TO_CHAR(mDataVctoDupl,''MM'')),00) = 00 THEN
> *****   mDataVctoDupl := pDataEmissao + mPrazoPgto;
>      END IF;
>      --
>      RETURN (mDataVctoDupl);
>    END;
>
> ' LANGUAGE 'plpgsql'
>
>     In the line marked with  " ***** "  it should be something like :
>
>      mDataVctoDupl := pDataEmissao + interval ''mPrazoPgto day'';

Perhaps you want something like:
pDataEmissao + interval ''1 day'' * mPrazoPgto;




view thread (2+ messages)

Message-ID: <20030819091906.S67349-100000@megazone.bigpanda.com>
Permalink:  ../20030819091906.S67349-100000@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20030819091906.S67349-100000@megazone.bigpanda.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, rhaoni@sistemica.info
  Subject: Re: Problems creating a function
  In-Reply-To: <20030819091906.S67349-100000@megazone.bigpanda.com>
  References: <1061309605.3f424ca5e30ee@sistemica.info> <20030819091906.S67349-100000@megazone.bigpanda.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