X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7794AD1B90C for ; Tue, 19 Aug 2003 13:13:40 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 95103-01 for ; Tue, 19 Aug 2003 13:13:30 -0300 (ADT) Received: from host2.hostseguro.com (unknown [200.198.188.133]) by svr1.postgresql.org (Postfix) with ESMTP id A1E01D1B991 for ; Tue, 19 Aug 2003 13:13:29 -0300 (ADT) Received: from cpanel by host2.hostseguro.com with local (Exim 4.20) id 19p96r-0000YF-W6 for pgsql-admin@postgresql.org; Tue, 19 Aug 2003 13:13:25 -0300 Received: from 200.180.188.66 ([200.180.188.66]) by sistemica.info (IMP) with HTTP for ; Tue, 19 Aug 2003 13:13:25 -0300 Message-ID: <1061309605.3f424ca5e30ee@sistemica.info> Date: Tue, 19 Aug 2003 13:13:25 -0300 From: Rhaoni Chiu Pereira To: pgsql-admin@postgresql.org Subject: Problems creating a function MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.180.188.66 X-MailScanner-Information: Verificado pelo McAfee VirusScan / Scanned by McAfee VirusScan X-MailScanner: Nao infectado / Found to be clean X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host2.hostseguro.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 32001] / [47 12] X-AntiAbuse: Sender Address Domain - sistemica.info X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/204 X-Sequence-Number: 9925 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''; BUT , this way the PostgreSQL treats the variable mPrazoPgto as a string and it must treat it like a variable and use its value. How do I make it understand mPrazoPgto as variable ? Atenciosamente, Rhaoni Chiu Pereira Sistêmica Computadores Visite-nos na Web: http://sistemica.info Fone/Fax : +55 51 3328 1122