return setof records
От | Chris Lukenbill |
---|---|
Тема | return setof records |
Дата | |
Msg-id | 1154032891.v2.fusewebmail-168507@ffuse18 обсуждение исходный текст |
Ответы |
Re: return setof records
|
Список | pgsql-sql |
Alright, first I'll apologize for asking this question another time. I've looked throught the archives and have found different ways on both the archives and different ways in the the documentation to do this and depending on which way I do it, I get different errors, so pick your poison on that. Everywhere I've looked the agreement was that making a call to the function had to be done as follows: SELECT * FROM sp_frontalerts_summary(1,'2006-07-27 18:08:09','2006-07-27 19:58:15' ) as (numitems int, region int); So there isn't a question on that. My question is, how do I return a "setof record" back to the application. I've tried the following ways: --------------------------------------------------------- CREATE OR REPLACE FUNCTION sp_frontalerts_summary (p_usernum int, p_lastlogin TIMESTAMP,p_now TIMESTAMP) RETURNS SETOF RECORD AS $$ DECLARE returnRecord RECORD; BEGIN FOR returnRecord in select count(item) as numitems,0 as region from frontalerts whereusernum=p_usernum and pinup=0 LOOP RETURN NEXT returnRecord; END LOOP; RETURN; END; $$ LANGUAGE plpgsql; --------------------------------------------------------- Also have tried it with EXECUTE after the "FOR returnRecord in" and before the "select count(item)..." Also have tried to do just a "select count(item) as numitems,0 as region from frontalerts where usernum=p_usernum and pinup=0" without any type of returning (only a "RETURNS SETOF RECORD AS $$..") (the way that the documentation talks about doing it in one area) Now this is a little of a simplified version, but I have the same problem with all of the stored procs. If you know what I'm doing wrong, please let me know. Or if you have anything I should possibly try, let me know that too. I've searched high and low and really thought I had it this time, but I guess not. Also, sorry for such an easy question, but I'm new to PostgreSQL so this port from MS SQL to PostgreSQL on someone else's code is kickin my butt. Thank you in adavance for any help. Chris
В списке pgsql-sql по дате отправления: