Select Scalar in PL / SQL - Oracle SQL Developer

0

I come from a T-SQL (MS SQL Server) background and have things that do not work the same in PL / SQL.

I would like to know how to give a select in PL / SQL scalars.

Examples in MS SQL Server

Example 1:

SELECT 1 + 1

Example 2:

DECLARE @variavel INT = 1

SELECT @variavel

How would I make these examples work in PL / SQL in Oracle SQL Developer?

    
asked by anonymous 09.04.2018 / 20:43

1 answer

1

For the cases of the above examples, I declare a variable using define , declare does not work.

In addition, to be able to work with the variable in a select I should add && to the front of the variable name at the time of the query:

define  
    a integer :=30
    select 'x' from dual where &&a = 31;
    select 'x' from dual where &&a = 30;
    select &&a from dual;
    select 1 + 1 from dual;
    select &&a + &&a from dual;
    
10.04.2018 / 14:14