How to put the result of selection into a table in a function?

65 views
Skip to first unread message

MINGMAN ZHENG

unread,
May 9, 2018, 8:02:21 AM5/9/18
to COMP9311 Project Q&A
How to put the result of selection into a table in a function?
So, I don't have to use the same selection again when I want to use the result in other place.
Thank you.

Wei Li

unread,
May 9, 2018, 8:40:15 AM5/9/18
to COMP9311 Project Q&A
create a variable with return type, and then insert value in selection result into the required attributes of defined variable. At last, return mentioned variable. For detail, pls refer to lecture.

Theruni Pethiyagoda

unread,
May 23, 2018, 5:28:23 AM5/23/18
to COMP9311 Project Q&A
Do something like this if you haven't already found it.

create or replace function fin2(org_id integer, num_courses ...) 
returns table (unswid int, student_name varchar(128), code char(8), ....)  
AS $BODY$ 
Select  unswid, student_name, ....
FROM fin(org_id, nu...) as fin;
$BODY$
 LANGUAGE sql;

On Wednesday, May 9, 2018 at 10:02:21 PM UTC+10, MINGMAN ZHENG wrote:
Reply all
Reply to author
Forward
0 new messages