Skip site navigation (1) Skip section navigation (2)

Function syntax ?

From: "Ruben Gouveia" <rubes7202(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Function syntax ?
Date: 2008-09-09 17:55:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Does this syntax look correct? Can anyone think of a better way to write

This function will accept two timestamp parameters and determine the highest
of the two?

create or replace function fcn_max_dt(p_dt timestamp without time zone,
                                      p_dt2 timestamp without time zone)
returns timestamp without time zone as $$
      v_dt timestamp without time zone;
      v_dt2 timestamp without time zone;

    v_dt := p_dt;
    v_dt2 := p_dt2;

    if v_dt >= v_dt2 then
    return v_dt;
    return v_dt2;
    end if;

$$ LANGUAGE 'plpgsql';


pgsql-sql by date

Next:From: Pavel StehuleDate: 2008-09-09 18:05:34
Subject: Re: Function syntax ?
Previous:From: Lennin CaroDate: 2008-09-09 14:36:44
Subject: Re: PL/pgSQL function syntax question?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group