Обсуждение: PlPg/SQL
Hi!
How can i return one more row form a pgpl/sql function?
CREATE OR REPLACE FUNCTION GetRows(INTEGER, INTEGER, INTEGER) RETURNS
TEXT AS $$
DECLARE
Rows table_name%ROWTYPE;
BEGIN
SELECT * INTO Rows FROM table1_name WHERE id = $1;
-- Return (1, 'Smis', 'smis@gmail.com')
SELECT * INTO Rows FROM table2_name WHERE id = $2;
-- Return (2, 'Ashle', 'Ashle@gmail.com')
SELECT * INTO Rows FROM table3_name WHERE id = $3;
-- Return (1, 'Galaxy University', 'g-uni@gmail.com')
RETURN Rows;
END;
$$ LANGUAGE 'plpgsql';
SELECT * FROM GetRows(1,2,3);
I want return for all 3 row in one table? How can i do that?
am Sat, dem 31.03.2007, um 15:40:56 -0700 mailte MaDog folgendes: > Hi! > > How can i return one more row form a pgpl/sql function? You can use a set-of-record - function for this: http://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-SQL-TABLE-FUNCTIONS or http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING (Read the user-comment) > > CREATE OR REPLACE FUNCTION GetRows(INTEGER, INTEGER, INTEGER) RETURNS You should better use an array(int) for a variable count of parameters. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net