![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
Semi-OT: Functions and Aggregates in PostgreSQLby notsoevil (Pilgrim) |
on Oct 16, 2001 at 22:47 UTC ( #119217=perlquestion: print w/replies, xml ) | Need Help?? |
notsoevil has asked for the wisdom of the Perl Monks concerning the following question:
You've probably noticed the topic is "Semi-OT". That's there because I am conflicted. My problem is not entirely centered about Perl (I used Perl as a Procedural language in PostgreSQL), but I have gotten to know that there is a breadth of knowledge here on other topics as well, due to the real-life experiences of my fellow monks. Now I am faced with a problem that may have been experienced by some of you out there, but I have no other effecient way of presenting you with it for advice.
So, I'll post here not seeking Perl Wisdom specifically, but seeking Wisdom of the Monks: I have a sub in a Perl script that loops fetching the following statement (prepare once, execute once, a while loop for fetchrow_array) And formats it like so: A variable ($link_list) is in the loop, holding the concatenated last statement with the new one. I would rather do this with FUNCTIONS (and/or AGGREGATES). So, I CREATEd a FUNCTION: So in my Perl script, the SQL statement becomes: However, I still have to loop with Perl -- it would be nice to use an AGGREGATE to do some of this for me. I can create an AGGREGATE but from what I can tell, the format of the sfunc can only have two parameters like so: Where the first parameter is what was passed before, and the second parameter is the 'new' info to do stuff to. Is it not possible to do something similar to?: So that I can pass the url and name to the AGGREGATE (so it can in turn pass it to the sfunc)? Where the sfunc could be something like so: Because then I gain benefit of a stored procedure and cut the SQL in the script down to: Which will return the entire list at once, instead of needing the script to loop through multiple fetches. ... Of course, I may be going about this in an entirely incorrect manner. Telling me so, with a bit of direction, would also be greatly appreciated.
--
Back to
Seekers of Perl Wisdom
|
|