How to declare and display a variable in Oracle

后端 未结 5 1254
广开言路
广开言路 2020-12-15 16:32

I would like to declare and display a variable in Oracle.

In T-SQL I would do something like this

DECLARE @A VARCHAR(10) --Declares @A
SELECT @A = \'         


        
5条回答
  •  青春惊慌失措
    2020-12-15 16:56

    Make sure that, server output is on otherwise output will not be display;

    sql> set serveroutput on;

    declare
      n number(10):=1;
    begin
      while n<=10
     loop
       dbms_output.put_line(n);
       n:=n+1;
     end loop;
    end;
    /
    

    Outout: 1 2 3 4 5 6 7 8 9 10

提交回复
热议问题