From thiago@nq.com.br Thu Jan 30 13:55:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E1CF9476022 for ; Thu, 30 Jan 2003 08:55:04 -0500 (EST) Received: from ginsberg.uol.com.br (ginsberg.uol.com.br [200.221.4.48]) by postgresql.org (Postfix) with ESMTP id 8FA74475FD4 for ; Thu, 30 Jan 2003 08:55:03 -0500 (EST) Received: from camburi ([200.221.43.133]) by ginsberg.uol.com.br (8.9.1/8.9.1) with SMTP id LAA02941 for ; Thu, 30 Jan 2003 11:52:38 -0200 (BRST) Message-ID: <00d001c2c86f$8414dcc0$0c00000a@camburi> From: "Thiago Conti" To: "pgsql-sql" Subject: Function executing twice Date: Thu, 30 Jan 2003 11:54:36 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00CD_01C2C856.5CBB8110" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/498 X-Sequence-Number: 11363 This is a multi-part message in MIME format. ------=_NextPart_000_00CD_01C2C856.5CBB8110 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I'm executing a function with this command: select function_name(aaa,bbb,ccc); When I do it on PSQL or PGAdmin it works perfectly. However, on my application the function is executed twice. Has anybody faced a problem like this? I'm using PostgreSQL 7.2.3 and ODBC conection.=20 Thanks ------=_NextPart_000_00CD_01C2C856.5CBB8110 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,
 
I'm executing a function with this=20 command:
select function_name(aaa,bbb,ccc);<= /DIV>
 
When I do it on PSQL or PGAdmin it works= =20 perfectly.
However, on my application the funct= ion is=20 executed twice.
 
Has anybody faced a problem like=20 this?
 
I'm using PostgreSQL 7.2.3 and ODBC conect= ion.=20
 
Thanks
------=_NextPart_000_00CD_01C2C856.5CBB8110-- From t.matiisen@aprote.ee Thu Jan 30 15:15:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C704E476373 for ; Thu, 30 Jan 2003 10:15:06 -0500 (EST) Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) by postgresql.org (Postfix) with ESMTP id 5C5A447751A for ; Thu, 30 Jan 2003 10:15:02 -0500 (EST) Received: Message by Barricade ns.aprote.ee with ESMTP id h0UFFc311203 for ; Thu, 30 Jan 2003 17:15:38 +0200 Received: from TAMBETM ([192.168.1.14]) by black.aprote.com with Microsoft SMTPSVC(5.0.2195.5329); Thu, 30 Jan 2003 17:15:04 +0200 Message-ID: <000c01c2c872$5d18ab80$0e01a8c0@aprote.com> From: "Tambet Matiisen" To: "Thiago Conti" , "pgsql-sql" References: <00d001c2c86f$8414dcc0$0c00000a@camburi> Subject: Re: Function executing twice Date: Thu, 30 Jan 2003 17:15:03 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-OriginalArrivalTime: 30 Jan 2003 15:15:04.0055 (UTC) FILETIME=[5D83F070:01C2C872] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/503 X-Sequence-Number: 11368 I think you should first check your application logic, for example print something out just before calling the function. Then you can easily see, if the problem is in PostgreSQL or in your application. I once had similar problem, when I used function as argument to COALESCE. COALESCE is translated to CASE before evaluating the arguments. For example COALESCE(id,nextval('id_seq')) becomes CASE WHEN id IS NOT NULL THEN id WHEN nextval('id_seq') IS NOT NULL THEN nextval('id_seq') ELSE NULL END. As you can see, when id is null, the sequence id_seq is incremented twice. Solution was quite simple, I just used CASE directly: CASE WHEN id IS NOT NULL THEN id ELSE nextval('id_seq') END. Tambet ----- Original Message ----- From: Thiago Conti To: pgsql-sql Sent: Thursday, January 30, 2003 4:54 PM Subject: [SQL] Function executing twice Hello, I'm executing a function with this command: select function_name(aaa,bbb,ccc); When I do it on PSQL or PGAdmin it works perfectly. However, on my application the function is executed twice. Has anybody faced a problem like this? I'm using PostgreSQL 7.2.3 and ODBC conection. Thanks