From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Rhaoni Chiu Pereira <rhaoni(at)sistemica(dot)info> |
Cc: | <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Problems creating a function |
Date: | 2003-08-19 16:20:09 |
Message-ID: | 20030819091906.S67349-100000@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
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;
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Miles | 2003-08-19 16:46:16 | This table won't use INDEX until I DUMP/RESTORE it ? |
Previous Message | Rhaoni Chiu Pereira | 2003-08-19 16:13:25 | Problems creating a function |