Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Problem with accept in PL/SQL

Re: Problem with accept in PL/SQL

From: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Thu, 13 Mar 2003 20:46:04 GMT
Message-ID: <MPG.18da8de3390a59d9896f4@news.la.sbcglobal.net>


worldkumaril_at_yahoo.com said...
> 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
>

I answered this in the other NG (c.d.o.server) just yesterday. Here's what I said:

Don't know if this is what you're looking for, but...

SQL> l
  1 declare
  2 arg varchar2(10);
  3 begin
  4 select '&dummy' into arg from dual;   5 dbms_output.put_line('arg='||arg);   6* end;
SQL> set serveroutput on size 1000000
SQL> /
Enter value for dummy: abcde
old 4: select '&dummy' into arg from dual; new 4: select 'abcde' into arg from dual; arg=abcde

PL/SQL procedure successfully completed.

SQL> 2
  2* arg varchar2(10);
SQL> c/varchar2(10)/number
  2* arg number;
SQL> 4
  4* select '&dummy' into arg from dual; SQL> c/'&dummy'/&dummy
  4* select &dummy into arg from dual; SQL> l
  1 declare
  2 arg number;
  3 begin
  4 select &dummy into arg from dual;   5 dbms_output.put_line('arg='||arg);   6* end;
SQL> /
Enter value for dummy: 123
old 4: select &dummy into arg from dual; new 4: select 123 into arg from dual; arg=123

PL/SQL procedure successfully completed.

SQL>

-- 
/Karsten
DBA > retired > DBA
Received on Thu Mar 13 2003 - 14:46:04 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US