error: query has no destination for result data

268 views
Skip to first unread message

Paula Kiatkamolwong

unread,
May 13, 2018, 3:40:32 AM5/13/18
to COMP9311 Project Q&A
Hi,

When I finished writing my function q1, I tried to run it with select * from q1(52491); but I kept getting the error message 

ERROR:  query has no destination for result data

HINT:  If you want to discard the results of a SELECT, use PERFORM instead.

CONTEXT:  PL/pgSQL function q1(integer) line 6 at SQL statement


In my q1 function I declared a variable roomrec RoomRecord.

I have sql queries select count(*) into roomrec.valid_room_number from ... where ... and select count(*) into roomrec.bigger_room_number from ... where ... and at the end of the function I return roomrec. 

I don't understand why I keep getting "query has no destination for result data" when I specified the destination to be roomrec.valid_room_number and roomrec.bigger_room_number. I know that my sql queries are valid because I tested them and got the correct numbers, but when I put everything into a function I kept getting the error message. If anyone could point out a suggestion or know if I'm missing something, that would be really helpful. I tried not to post my whole queries here, but if that made it impossible to tell my mistakes I'd stop by at the lab instead. 


Thanks in advance!
Paula 

Wei Li

unread,
May 13, 2018, 3:55:40 AM5/13/18
to COMP9311 Project Q&A
There is no problem with your logic. Since you return a variable of "RoomRecord", you can check your return type of your function which should be "returns RoomRecord". If not works, you can ask tutor for help at lab time.
Reply all
Reply to author
Forward
0 new messages