Re: [SQL] Is there a conditional string-concatenation ?

2010-10-11 Thread Osvaldo Kussama
2010/10/12 Andreas : >  Hi, > Is there a conditional string-concatenation ? > > I'd like to have an elegant way to connect 2 strings with some 3rd element > between only if there really are 2 strings to connect. > > e.g. > MyCat ( 'John', '_', 'Doe' ) --> 'John_Doe' > while > MyCat ( 'John', '_', '

Re: [SQL] Is there a conditional string-concatenation ?

2010-10-11 Thread Joshua Tolley
On Tue, Oct 12, 2010 at 06:09:07AM +0200, Andreas wrote: > Hi, > Is there a conditional string-concatenation ? Perhaps this: CREATE OR REPLACE FUNCTION mycat(text, text, text) RETURNS TEXT LANGUAGE sql IMMUTABLE AS $$ SELECT CASE WHEN $1 IS NULL OR $1 = '' THEN trim($3) WHEN $3 IS NULL O

[SQL] Is there a conditional string-concatenation ?

2010-10-11 Thread Andreas
Hi, Is there a conditional string-concatenation ? I'd like to have an elegant way to connect 2 strings with some 3rd element between only if there really are 2 strings to connect. e.g. MyCat ( 'John', '_', 'Doe' ) --> 'John_Doe' while MyCat ( 'John', '_', '' ) --> 'John' MyCat ( '', '_', 'Doe

Re: [SQL] get attribute from XML

2010-10-11 Thread Markus Schatten
Dear Viktor, 'modified' is an attribute node, so you need to use the @ sign to acquire its value: mschatte=# select xpath( '//entry/@modified', '' ); xpath -- {2009-07-07} (1 row) HTH M.S. On Tue, Oct 12, 2010 at 1:03 AM, Viktor Bojović wrote: > Hi, > while parsing this type

[SQL] get attribute from XML

2010-10-11 Thread Viktor Bojović
Hi, while parsing this type of XML: Q91G55 i tried this query to get the modified attribute select xpath('//entry/modified/text()',xml) from xml_sprot limit 10; but it doesn't work. So im asking if anyone can help me with that. Thanx in advance -- --- Viktor