DUMMY DATA
tblA (filled)
create table tblA (id varchar(5) PRIMARY KEY, method text, species varchar(10), location
text);
insert into tblA values ('1a', 'mtd1', 'sp1', 'locA'),('1b', 'mtd1', 'sp2', 'locC'),('1c',
'mtd2', 'sp3', 'locB'),('1d', 'mtd1', 'sp1', 'locB'),('1e', 'mtd2', 'sp5', 'locA');
retrieve_info_tbl (empty)
create table retrieve_info_tbl (id varchar(5) PRIMARY KEY, method text, ind varchar(10),
location text);
Calling function
SELECT * FROM retrieve_info('mtd1','sp1');
Since I have not succeeded in this, I tried to work around it creating a function which called this function and printed the result to a .csv file.
CREATE FUNCTION print_out(x TEXT, y TEXT) RETURNS void AS $$COPY (SELECT * FROM retrieve_info(x,y)) TO 'myfilepath/test.csv' WITH CSV HEADER;
$$ LANGUAGE 'sql';
Calling nested function.
SELECT * FROM print_out('mtd1','sp1');