Re: problem with SQL*plus loops
Date: Wed, 14 May 2003 20:56:59 -0500
Message-ID: <PM6dnWjUK7F2bl-jXTWcqw_at_comcast.com>
[Quoted] In article <4a678c58.0303130026.10866a67_at_posting.google.com>, worldkumaril_at_yahoo.com wrote:
>My name is Kumaril Bhatt and I know SQL*plus. I am not that familiar
>with PL/SQL. I want use loops in PL/SQL with user interaction. So I
>tried using an accept statement in a PL/SQL loop. But I got errors.
What kind of errors?
[Quoted] How are you invoking the script? ACCEPT requires you invoke it with
the _at_<filename> format.
>DECLARE
>ans char(1) :='y';
>cid char(4);
>vid char(4);
>vname varchar(15);
>
>begin
>
>while(ans = 'y')
>
>accept cid prompt "Enter customer id : ";
>accept vid prompt "Enter video id : ";
>accept vname prompt "Enter videoname : ";
>
>insert hire
>values (cid,vid,vname);
>
>accept ans prompt "Any more y/n : ";
>
>end;
[Quoted] I would make ans a BOOLEAN type initialized to TRUE so it looks something like:
BEGIN
WHILE process_another
LOOP
BEGIN
ACCEPT cid prompt ... ACCEPT vid prompt... ACCEPT vname prompt...
INSERT...
ACCEPT ans prompt
IF UPPER(ans) = "Y" THEN
process_another := FALSE END IF;
END LOOP;
END;
-- ====================================================================== ISLAM: Winning the hearts and minds of the world, one bomb at a time.Received on Thu May 15 2003 - 03:56:59 CEST