pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
create function(date,date,date,...)
2+ messages / 2 participants
[nested] [flat]

* create function(date,date,date,...)
@ 1999-09-25 17:51 Radek Kanovsky <radekk@uh.cz>
  1999-09-25 22:46 ` Re: [SQL] create function(date,date,date,...) Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Radek Kanovsky @ 1999-09-25 17:51 UTC (permalink / raw)
  To: pgsql-sql

Hi,

i am trying to declare function that gets six date arguments
and returns some status according actual date. It looks like
this:

CREATE FUNCTION datum_ok(DATE,DATE,DATE,DATE,DATE,DATE) RETURNS TEXT AS '
DECLARE
  tests         ALIAS FOR $1 ;
  teste         ALIAS FOR $2 ;
  payments      ALIAS FOR $3 ;
  paymente      ALIAS FOR $4 ;
  interrupts    ALIAS FOR $5 ;
  interrupte    ALIAS FOR $6 ;
  today         DATE ;
BEGIN
  today := now()::date ;
  .....

It happens that when some argument is NULL, than all argument get NULL.
It works correctly only when all arguments are not NULL.

SELECT
   login,
   datum_ok(
     test_start, test_end,
     payment_start, payment_end,
     interrupt_start, interrupt_end )
FROM service ;

How can I mix NULL and DATE values in arguments?

Thanks

Radek Kanovsky, rk@uh.cz




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] create function(date,date,date,...)
  1999-09-25 17:51 create function(date,date,date,...) Radek Kanovsky <radekk@uh.cz>
@ 1999-09-25 22:46 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 1999-09-25 22:46 UTC (permalink / raw)
  To: Radek Kanovsky <radekk@uh.cz>; +Cc: pgsql-sql

Radek Kanovsky <radekk@uh.cz> writes:
> It happens that when some argument is NULL, than all argument get NULL.
> It works correctly only when all arguments are not NULL.
> How can I mix NULL and DATE values in arguments?

Right now, you can't.  The function-call interface inside Postgres
is misdesigned (in several ways, but the one that's important here
is that only one argument-is-NULL flag gets passed to the function
from the expression evaluator).

Fixing this is on the to-do list, and should get done for 6.6 or 6.7.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-09-25 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-25 17:51 create function(date,date,date,...) Radek Kanovsky <radekk@uh.cz>
1999-09-25 22:46 ` Tom Lane <tgl@sss.pgh.pa.us>

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