Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get input from user at runtime

I want to take runtime input from user in Oracle 10g PL/SQL blocks (i.e. interactive communication with user). Is it possible?

declare
x number;
begin
x=&x;
end

this code gives error as

& can't be used in oracle 10g

like image 448
Ravindra Bagale Avatar asked Sep 20 '12 16:09

Ravindra Bagale


People also ask

How do you take inputs from runtime?

BusinessWorks framework passes the input to the processContext parameter in the public N execute(N input, ProcessContext<N> processContext) method, which can be used to retrieve the actual value of a field. You can find this method in the ActivityName _ ActivityType Activity.

How do you take user input in SQL?

The ACCEPT command is used to obtain input from the user. With it, you specify a user variable and text for a prompt. The ACCEPT command displays the prompt for the user, waits for the user to respond, and assigns the user's response to the variable.

How are they used to capture input from the user?

The simplest way to obtain user input is by using the input() function. This function prompts the user for an input from the keyboard. Once the user has give the input and pressed Enter, the program flow continues.


2 Answers

    a number;
    b number;
    begin
    a:= :a;-- instead of "&" use ":" here 
    b:= :b;
    if a>b then
    dbms_output.put_line('Large number is '||a);
    else
    dbms_output.put_line('Large number is '||b);
    end if;

end;

Actually when I tried this it worked perfectly and actually "&" is giving error so you can use ":".

hope it you got answer :)

like image 79
godofgod Avatar answered Nov 16 '22 10:11

godofgod


you can try this too And it will work:

DECLARE
  a NUMBER;
  b NUMBER;
BEGIN
  a := &aa; --this will take input from user
  b := &bb;
  DBMS_OUTPUT.PUT_LINE('a = '|| a);
  DBMS_OUTPUT.PUT_LINE('b = '|| b);
END;
like image 24
Muhammad Ali Avatar answered Nov 16 '22 09:11

Muhammad Ali