Unix Technical Forum

Re: SRFs returning records from a view

This is a discussion on Re: SRFs returning records from a view within the Pgsql General forums, part of the PostgreSQL category; --> > -------- Original Message -------- > Subject: Re: [GENERAL] SRFs returning records from a view > From: "Joshua D. ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:13 PM
mark.lubratt@indeq.com
 
Posts: n/a
Default Re: SRFs returning records from a view



> -------- Original Message --------
> Subject: Re: [GENERAL] SRFs returning records from a view
> From: "Joshua D. Drake" <jd@commandprompt.com>
> Date: Wed, June 01, 2005 4:39 pm
> To: mark.lubratt@indeq.com
> Cc: pgsql-general@postgresql.org
>
> mark.lubratt@indeq.com wrote:
> > Hello!
> >
> > I have a view that I'm putting into a report in my application. I'd
> > like to get several blank lines returned by the view as well as the
> > legitimate data (to leave room in the report for manual entries). I
> > thought I could make a SRF that would return the data from the view and
> > then spit out a number of blank records.
> >
> > As a first step in getting my SRF feet wet, I tried:
> >
> > CREATE OR REPLACE FUNCTION bluecard(int4)
> > RETURNS SETOF view_bluecard AS
> > $BODY$declare
> > r view_bluecard%rowtype;
> > begin
> > for r in select * from view_bluecard where job_id = jn loop
> > return next r;
> > end loop;
> > return;
> > end;$BODY$
> > LANGUAGE 'plpgsql' VOLATILE;
> >
> > where view_bluecard is the view that is already defined. When I try
> >
> > select bluecard(1130);

>
> select * from bluecard(1130)?
>


Sorry, 1130 is the job_id for the select's where clause in the function.
Does that make sense?

If I execute:

select * from view_bluecard where job_id = 1130;

I get the proper set of records. But, I want to add to them in the SRF
as I explained above. Thus, I don't think I can do it with just a view
(even using a union within the view as I don't know how many blanks the
user willl want).

Regards,
Mark



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:24 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com