Re: How to loop through records in a data block?

From: Frank van Bortel <f.van.bortel_at_vnl.nl>
Date: Mon, 26 Apr 1999 09:32:06 +0200
Message-ID: <37241675.DF8E0439_at_vnl.nl>


Hmmm sounds familiar. What demo are you working?

Some remarks regarding you modeling (this is _no_ answer to your question, but may prevent future problems/questions)

You relate customers to rentals to tapes and movies. I miss a rental item table (unless you mean to model one rental for each item).

A one-to-one relationship usually means the data should be merged into one table (or entity). I would have expected this, as there are too many common attributes: name, category, location, status, etc, etc.

That would have resolved you problem, as there are just inventory items on a rental. These items can be a tape, or a movie (btw: aren't movies usually on tape?).

Think it over.

suisum_at_ecn.ab.ca wrote:

> Thank you very very much for all of your help. May I redefine the problem
> I have, please?
>
> I want to list out all rentals records for a customer. I put
> four data blocks: Customers, Rentals, Tapes, and Movies. I
> also build a canvas as follow. Basically, the tape_id
> and movie_id is one-to-one relationship.
>
> Rentals data block Tapes Movies data block
> +-------------------+ +----------------+ +-----------------------+
> |Tape_id, Rent_date | |Tape_id,Movie_id| |Movie_id, Title, Status|
> | | | | | |
> | | | | | |
> | | | | | |
> | | | | | |
> +-------------------+ +----------------+ +-----------------------+
>
> To populate the data for the Movies block, I created a trigger
> ON-POPULATE-DETAILS in the Rentals block. However, I received the
> message 'Do you want to save the change you have made?' when the
> statement 'GO_BLOCK('RENTALS')' was executed. If I answered 'Yes',
> it complained that 'Unable to insert record'. Then, it listed
> the corresponding movies records in the Movies block. But if
> I answered 'No' or 'Cancel', it went for an infinitive loop.
>
> Please help.
>
> IF ( (:RENTALS.TAPE_ID is not null) ) THEN
> FIRST_RECORD;
> LOOP
> GO_BLOCK ('MOVIES');
> FOR cur_movies IN cur_movies_rec LOOP
> :movies.id := cur_movies.id;
> :movies.title := cur_movies.title;
> :movies.status := cur_movies.status;
> NEXT_RECORD;
> END LOOP;
> GO_BLOCK ('RENTALS'); <------ Problem here!!!!
> EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
> NEXT_RECORD;
> END LOOP;
> FIRST_RECORD;
> END IF;
>
> Steve Cosner (stevec_at_zimmer.csufresno.edu) wrote:
> : In article <37212bdb.0_at_ecn.ab.ca>, <suisum_at_ecn.ab.ca> wrote:
> : >I need to loop through all records in a data block. What is the condition
> : >for the WHILE loop, please?
> : >
> : >I have tried WHILE :SYSTEM.LAST_RECORD = 'FALSE' LOOP
> : >or WHILE :data_block.item IS NOT NULL LOOP
>
> : Go_Block('Your_Block');
> : First_Record;
> : IF :System.Record_Status<>'NEW' then
> : Loop
> : -- do something here --
> : Exit when :system.last_record = 'TRUE';
> : Next_Record;
> : End Loop;
> : First_Record;
>
> : Steve Cosner
> : ----------------------------------------------------------------------
> : http://members.aol.com/stevec5088
> : Downloadable Quick Access utility form: Display and update any table.
>
> --
> Best regards,

--
Met vriendelijke groet,
kind regards,

Frank van Bortel
Technical consultant Oracle
V&L Informatica BV
-----------------------------------------------
Work                           Home
Postbus 545                    Hunzestraat 4
7500 AM Enschede               7555 WB Hengelo
(31)53.434.1500                (31)74.242.5046
Received on Mon Apr 26 1999 - 09:32:06 CEST

Original text of this message