Home » SQL & PL/SQL » SQL & PL/SQL » Simple questions
Simple questions [message #39595] Thu, 25 July 2002 07:03 Go to next message
Wilson
Messages: 9
Registered: February 2002
Junior Member
(1) How to prompt for user input at runtime in PL/SQL block ? Just like ACCEPT / PROMPT keyword in SQL*Plus

(2) How to exit a program without using CTRL C to break the execution ?

Please help. Thank you very much
Re: Simple questions [message #39597 is a reply to message #39595] Thu, 25 July 2002 08:53 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
1. use a substitution variable '&' to take the input
   from user.
2. use the EXIT statement to exit.
SQL> ed
Wrote file afiedt.buf

  1  begin
  2  for mag in 1..&max_value loop
  3  dbms_output.put_line(mag);
  4  exit when mag=10;
  5  end loop;
  6* end;
SQL> /
Enter value for max_value: 30
old   2: for mag in 1..&max_value loop
new   2: for mag in 1..30 loop
1
2
3
4
5
6
7
8
9
10

PL/SQL procedure successfully completed.

Previous Topic: Creating a temporary view or table
Next Topic: SQL Statement
Goto Forum:
  


Current Time: Fri Apr 19 09:52:36 CDT 2024