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: Bob Fazio <bob_fazio_at_hotmail.com.no.spam>
Date: Thu, 09 Sep 1999 04:57:37 GMT
Message-ID: <57HB3.3843$E46.10722@news.rdc1.pa.home.com>


Yes you can loop as other post's have stated

declare
cursor c1 is select * from tname;
begin
for x in c1
loop

    ... Do what you want referencing x.column_name; end loop;
end;
/

But more importantly, I can't see an real reason for not making it 3 columns.

do a describe on sys.all_source for a very similar setup.

SQL> desc sys.all_source;

 Name                            Null?    Type
 ------------------------------- -------- ----
 OWNER                           NOT NULL VARCHAR2(30)
 NAME                            NOT NULL VARCHAR2(30)
 TYPE                                     VARCHAR2(12)
 LINE                            NOT NULL NUMBER
 TEXT                                     VARCHAR2(4000)

In the above owner and name would be similar to your customer number

Line would be like your record number

and text would be similar to customer description.

Changing the table would give you a lot more flexability.

<mitch23_at_hotmail.com> wrote in message news: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 - 23:57:37 CDT

Original text of this message

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