Databases

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Fwd: Help with function

    2 answers - 1668 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Just curious but since which version these IN/UT parameters are supported?
    -- Matthias
    Message
    From: pgsql-general-owner (AT) postgresql (DOT) org
    [mailto:pgsql-general-owner (AT) postgresql (DOT) org] Behalf A. Kretschmer
    Sent: Wednesday, 04, 2006 4:01 PM
    To: pgsql-general (AT) postgresql (DOT) org
    Subject: Re: [GENERAL] Fwd: Help with function
    am Wed, dem 04.10.2006, um 9:31:28 -0400 mailte Chris
    Hoover folgendes:
    Here is my attempt at the function (note, this is a simple
    example that could
    obviously be done via a view, but I am trying to learn more
    about writing
    plpgsql functions):
    create or replace function dba.active_transactions_by_db()
    returns setof
    integer pg_stat_activity.datname%TYPE as
    $BDY$
    declare
    dbName varchar;
    activeTransactions integer;
    countRec record;
    begin
    for countRec in select count(1) as cnt, datname from
    pg_stat_activity group
    by datname loop
    return next countRec;
    end loop;
    return countRec;
    end;
    $BDY$
    language plpgsql;
    I wrote for you this:
    create or replace function active_transactions_by_db(out _cnt
    int, out _datname text) returns setof record as
    $BDY$
    declare
    dbName varchar;
    activeTransactions integer;
    countRec record;
    begin
    for countRec in select count(1) as cnt, datname from
    pg_stat_activity group by datname loop
    _cnt := countRec.cnt;
    _datname := countRec.datname;
    return next;
    end loop;
    return;
    end;
    $BDY$
    language plpgsql;
    It works.
    If you want lern more about IN and UT - Parameters, see:
    #extended
    HTH, Andreas
  • No.1 | | 257 bytes | |

    am Wed, dem 04.10.2006, um 16:06:40 +0200 mailte Matthias.Pitzl (AT) izb (DOT) de folgendes:
    Just curious but since which version these IN/UT parameters are supported?
    I'm not sure, 8.0 or 8.1
    [ silly fullquote deleted ]
    Andreas
  • No.2 | | 333 bytes | |

    am Wed, dem 04.10.2006, um 16:06:40 +0200 mailte Matthias.Pitzl (AT) izb (DOT) de folgendes:
    Just curious but since which version these IN/UT parameters are supported?

    Since 8.1:

    E.6.3.8. General Server-Side Language Changes
    Allow SQL and PL/PgSQL functions to use UT and INUT parameters (Tom)

    HTH, Andreas

Re: Fwd: Help with function


max 4000 letters.
Your nickname that display:
In order to stop the spam: 6 + 5 =
QUESTION ON "Databases"

EMSDN.COM