Re: problem with SQL*plus loops

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Thu, 13 Mar 2003 08:30:14 -0800
Message-ID: <3E70B216.E07D1346_at_exesolutions.com>


Kumaril Bhatt wrote:

> Hi everybody,
> 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. I
> dont know much about scripts. So if any one could provide me with a
> script, so that the loop below can be executed. The loop asks the user
> whether he wants to insert more rows.
>
> 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;
>
> Thank You very Much
> Kumaril

The syntax for a loop is:

WHILE ans = 'y'
LOOP

  • do stuff here END LOOP;
And if you don't cast UPPER or LOWER the wrong case 'y' will end the loop.

Daniel Morgan Received on Thu Mar 13 2003 - 17:30:14 CET

Original text of this message