Re: problem with SQL*plus loops

From: Jeff <jeff_at_work.com>
Date: Fri, 14 Mar 2003 14:00:55 GMT
Message-ID: <b4snan$clv$2_at_cronkite.cc.uga.edu>


[Quoted] Beyond, the simple PL/SQL syntax correction, he can't do what he's proposing, can he? 'Accept' is a SQL*plus command, which won't compile inside a PL/SQL block, right? At best, I'd think, he can use one of the DBMS_OUTPUT (or whichever package) procedures written for accepting user input.

In article <3E70B216.E07D1346_at_exesolutions.com>, DA Morgan <damorgan_at_exesolutions.com> wrote:
>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 Fri Mar 14 2003 - 15:00:55 CET

Original text of this message