Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Can I use loop logic in Oracle SQL?

Re: Can I use loop logic in Oracle SQL?

From: Christian Curtis <cbcurtis_at_mediaone.net>
Date: Thu, 09 Sep 1999 02:55:23 GMT
Message-ID: <vkFB3.3791$Ud2.82517@typhoon1.rdc-detw.rr.com>


I'm not sure if this is what you want, but you could probably create a crosstab-type query to have only 1 row of data for each record number.

As in:

    Select

        decode(record_number,1,customer_description) customer_description_1,
        decode(record_number,2,customer_description) customer_description_2,
        decode(record_number,3,customer_description) customer_description_3,
        decode(record_number,4,customer_description) customer_description_4
    from
        Customer_table
    group by
        CustomerID

then you can just concatenate Customer_description_1 || customer_Description_2 || .... to get your total description.

Hope this helps.,

Cris

mitch23_at_hotmail.com wrote in message <7r6kka$4di$1_at_nnrp1.deja.com>...
>I'm new to Oracle, so excuse me if this is a silly question.
>
>There is this table that stores the contents of a free-form text field
>(let's call it customer_description) that is structured a little
>strangely. There are three files in the table, a primary key
>(customerID), a counter field (record_number), and then the actual
>text field. The way this table is setup,each line item in the free
>form text field gets a single record.
>
>
>For example, if CustomerID 1234 has a 4 line Customer_description,
>there will be 4 records in this table as follows:
>
>CustomerID Record_Number Customer_Description
>---------------------------------------------------
>1234 1 text...
>1324 2 ...continued text
>1234 3 ...continued text
>1324 4 ...continued text
>9999 1 text...
>9999 2 ...continued text
>
>
>How can I loop through this table so that I can concantenate the
>contents of the description field by Customer ID?
>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Wed Sep 08 1999 - 21:55:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US