pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tambet Matiisen <t.matiisen@aprote.ee>
To: Thiago Conti <thiago@nq.com.br>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Function executing twice
Date: Thu, 30 Jan 2003 17:15:03 +0200
Message-ID: <000c01c2c872$5d18ab80$0e01a8c0@aprote.com> (raw)
References: <00d001c2c86f$8414dcc0$0c00000a@camburi>

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




view thread (2+ messages)

Message-ID: <000c01c2c872$5d18ab80$0e01a8c0@aprote.com>
Permalink:  ../000c01c2c872$5d18ab80$0e01a8c0@aprote.com/
Also on:    postgresql.org/message-id/000c01c2c872$5d18ab80$0e01a8c0@aprote.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: t.matiisen@aprote.ee, thiago@nq.com.br
  Subject: Re: Function executing twice
  In-Reply-To: <000c01c2c872$5d18ab80$0e01a8c0@aprote.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