[Postgresql-it] SetOf

  • From: Enrico <scotty@xxxxxxxxxxxx>
  • To: Pg-mailing <postgresql-it@xxxxxxxxxxxxxxxxx>
  • Date: Wed, 06 Apr 2005 12:29:01 +0200

Problema vorrei creare una funzione che mi restituisca la setof di due campi è possible?

Cioè se scrivo:

CREATE OR REPLACE FUNCTION f (int4,int8) RETURNS SETOF table1 AS '
select AB.*
from table1 AB inner join table2 B on AB.campo=B.campo
where B.campo2 = $1
and AB.campo1 < $2
order by 1;
' LANGUAGE SQL


va tutto ok.Iil problema è che table1 ha supponiamo 10 campi e a me interessa che la query che mi ritorni solo due campi, per interderci vorrei fare qualcosa del genere:

CREATE OR REPLACE FUNCTION f (int4,int8) RETURNS SETOF qualcosa AS '
select AB.campo1,AB.campo2
from table1 AB inner join table2 B on AB.campo=B.campo
where B.campo2 = $1
and AB.campo1 < $2
order by 1;
' LANGUAGE SQL

esiste un tipo predefinito per fare questa cosa oppure un modo per creare un tipo composito ?

Enrico


Other related posts:

  • » [Postgresql-it] SetOf - Enrico