Oracle PL/SQL - Assigning values to variables

Introduction

There are a number of ways to assign a value to a variable.

Demo

SQL>
SQL> declare-- from  w ww. j a va2  s  .  c  o m
  2        v_length_nr NUMBER DEFAULT 5;
  3        v_height_nr NUMBER := 4;
  4        v_width_nr  NUMBER;
  5        v_volume_nr NUMBER;
  6        v_min_nr    NUMBER;
  7
  8  begin
  9        v_width_nr := 3;
 10        v_volume_nr:= v_length_nr*v_width_nr*v_height_nr;
 11        v_min_nr := least(v_length_nr,v_width_nr,v_height_nr);
 12
 13        DBMS_OUTPUT.PUT_LINE(v_width_nr);
 14        DBMS_OUTPUT.PUT_LINE(v_volume_nr);
 15        DBMS_OUTPUT.PUT_LINE(v_min_nr);
 16  end;
 17  /
3
60
3

PL/SQL procedure successfully completed.

Related Topic