RE: [SQL] List Concatination [warning]

2001-05-02 Thread Wilkinson Charlie E
Title: RE: [SQL] List Concatination [warning] A word of warning for the newbies... *Don't* create a function called textcat.  You *will* be sorry.  There's already a textcat builtin and you kinda need it for || and whatnot. (Yes, I found out the hard way...) There might be a bet

Re: [SQL] List Concatination

2001-03-16 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > As I said in my previous e-mail, I appear to have gotten the list to > order itself by basing it on an (ordered) sub-select. Since the DB is > only 50% populated right now, I'm not sure that's working perfectly but > I'll keep you posted. Yes, that oug

Re: [SQL] List Concatination

2001-03-16 Thread Josh Berkus
Tom, > Yes, that oughta work fine to determine the order of inputs to the > aggregate function. ORDER BY in sub-selects is a new feature (heck, > sub-selects in FROM at all is a new feature) in 7.1, so this trick > wasn't available when Richard and I discussed the issue before. Hey, why do you

Re: [SQL] List Concatination

2001-03-16 Thread Josh Berkus
Richard, > Sorry - issue was to do with the ordering of the concatenation, not > the > user-defined aggregates (iirc - it's getting late here). > > I do remember I got different orders when selecting and updating. In > my > case it didn't matter, and I'm guessing if the order reverses in your

Re: [SQL] List Concatination

2001-03-15 Thread Richard H
On 3/15/01, 5:02:37 PM, Tom Lane <[EMAIL PROTECTED]> wrote regarding Re: [SQL] List Concatination : > Josh Berkus <[EMAIL PROTECTED]> writes: > >> Note that this is probably not a good idea - the ordering of the > >> contacts will not be well-defined. Whe

Re: [SQL] List Concatination

2001-03-15 Thread Tom Lane
Josh Berkus <[EMAIL PROTECTED]> writes: >> Note that this is probably not a good idea - the ordering of the >> contacts will not be well-defined. When I asked about this Tom Lane was >> quite surprised that it worked, so no guarantees about long-term >> suitability. > Hmmm ... this feature is ver

Re: [SQL] List Concatination

2001-03-15 Thread Josh Berkus
Richard, I wanted to thank you for the concatination suggestion ... on testing, a custom aggregate *was* faster than procedural concatination ... much faster. > But - if you don't care about the order of contacts you can define an > aggregate function: > > create aggregate catenate(sfun

Re: [SQL] List Concatination

2001-03-09 Thread Josh Berkus
Tom, Richard, Thanks for the advice, guys! This being Postgres, I *knew* there would be other options. > > create aggregate catenate(sfunc1=textcat, basetype=text, > stype1=text, initcond1=''); > > > Then group by client and catenate(firstname || ' ' || lastname) > > With a custom agg

Re: [SQL] List Concatination

2001-03-09 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > But - if you don't care about the order of contacts you can define an > aggregate function: > create aggregate catenate(sfunc1=textcat, basetype=text, stype1=text, initcond1=''); > Then group by client and catenate(firstname || ' ' || lastname) With

Re: [SQL] List Concatination

2001-03-09 Thread Richard Huxton
Josh Berkus wrote: > I have an interesting problem. For purpose of presentation to users, > I'd like to concatinate a list of VARCHAR values from a subtable. To > simplify my actual situation: > > What I'd like to be able to do is present a list of clients and their > comma-seperated co

[SQL] List Concatination

2001-03-08 Thread Josh Berkus
Folks, I have an interesting problem. For purpose of presentation to users, I'd like to concatinate a list of VARCHAR values from a subtable. To simplify my actual situation: CREATE TABLE clients ( client_id SERIAL PRIMARY KEY, client_name VARCHAR(50) ); CREATE TABLE c