Re: problem with SQL*plus loops
From: Frank <fvanbortel_at_netscape.net>
Date: Thu, 15 May 2003 21:48:14 +0200
Message-ID: <3EC3EEFE.2070505_at_netscape.net>
>
>
> What kind of errors?
> How are you invoking the script? ACCEPT requires you invoke it with
> the _at_<filename> format.
>
>
>
>
> 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;
>
Date: Thu, 15 May 2003 21:48:14 +0200
Message-ID: <3EC3EEFE.2070505_at_netscape.net>
Ubiquitous wrote:
> 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?
> 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;
>
>
> 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;
>
Bottom line: PL/SQL does *not* interact with the user... SQL does. As described in your example...
-- Regards, Frank van BortelReceived on Thu May 15 2003 - 21:48:14 CEST
