Re: Return rows as 1 line?
From: Mladen Gogala <gogala.mladen_at_gmail.com>
Date: Tue, 18 May 2010 01:36:15 +0000 (UTC)
Message-ID: <hssquf$rbd$1_at_news.eternal-september.org>
On Mon, 17 May 2010 14:02:24 -0700, joel garry wrote:
>> Hi,
>>
>> Ok, I am hoping this is now going to be nuts, but say I have data like
>> this:
>>
>> ID PRODUCT SKU
>> 1 ABC 123
>> 1 DEF 456
>> 2 XYZ 000 2 MNO 999
>> 3 GHI 888
>>
>> And this is what I would need:
>>
>> 1,ABC:123,DEF:456
>> 2,XYZ:000,MNO:999
>> 3,GHI:888
>>
>> So, records that have a certain criteria would have certain columns
>> concatenated. I'm thinking of putting together a dynamic query and
>> then opening a cursor and selecting from it, creating the string as I
>> go along.
>>
>> Any thoughts? I'm going to go with the dynamic cursor unless someone
>> else has a better idea.
>
> http://asktom.oracle.com/pls/asktom/f? p=100:11:4579694231612304::::P11_QUESTION_ID:229614022562 >
> jg
Date: Tue, 18 May 2010 01:36:15 +0000 (UTC)
Message-ID: <hssquf$rbd$1_at_news.eternal-september.org>
On Mon, 17 May 2010 14:02:24 -0700, joel garry wrote:
> On May 17, 1:17 pm, The Magnet <a..._at_unsu.com> wrote:
>> Hi,
>>
>> Ok, I am hoping this is now going to be nuts, but say I have data like
>> this:
>>
>> ID PRODUCT SKU
>> 1 ABC 123
>> 1 DEF 456
>> 2 XYZ 000 2 MNO 999
>> 3 GHI 888
>>
>> And this is what I would need:
>>
>> 1,ABC:123,DEF:456
>> 2,XYZ:000,MNO:999
>> 3,GHI:888
>>
>> So, records that have a certain criteria would have certain columns
>> concatenated. I'm thinking of putting together a dynamic query and
>> then opening a cursor and selecting from it, creating the string as I
>> go along.
>>
>> Any thoughts? I'm going to go with the dynamic cursor unless someone
>> else has a better idea.
>
> http://asktom.oracle.com/pls/asktom/f? p=100:11:4579694231612304::::P11_QUESTION_ID:229614022562 >
> jg
To tell the truth, I don't really like Tom's answer, either. Oracle is a relational database. Relational databases should return the requested rows, as quickly as possible. Relational databases are not formatting tools. Formatting the output is a job for the client tools, not for Oracle.
-- http://mgogala.byethost5.comReceived on Mon May 17 2010 - 20:36:15 CDT