Auf Thema antworten

[code]

postgres=# create table foo (id int primary key, val int);

CREATE TABLE

postgres=# insert into foo values (1,100);

INSERT 0 1

postgres=# insert into foo values (2,200);

INSERT 0 1

postgres=# create or replace function foo_count(_id int) returns setof bigint as $$begin return query select count(*) from foo where id = _id; end;$$language plpgsql;

CREATE FUNCTION

postgres=# select * from foo_count(1);

 foo_count

-----------

         1

(1 row)


postgres=# select * from foo_count(3);

 foo_count

-----------

         0

(1 row)


postgres=#

[/code]


Zurück
Oben