Re: problem with SQL*plus loops

From: DA Morgan <damorgan_at_exxesolutions.com>
Date: Fri, 14 Mar 2003 08:04:56 -0800
Message-ID: <3E71FDA8.DD86DAED_at_exxesolutions.com>


Jeff wrote:

> 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
> >

[Quoted] No. I was just addressing the syntax problem with the loop as others had already told him it couldn't be done.

I saw no reason to repeat that advise.

Daniel Morgan Received on Fri Mar 14 2003 - 17:04:56 CET

Original text of this message