Mr John
Mr John

Reputation: 241

SQL variable creation

What is the below language? I ran across this in a .sql file and never seen this before...Guessing we are creating variables but never seen it done this way.

column set_schema_pow new_value schema_pow

select variable_value set_schema_pow 
from &schema..var 
where
loc = 'PROD' 
and atom = '&vta' 
and variable_name = 'schema_pow';

Upvotes: 0

Views: 40

Answers (1)

Littlefoot
Littlefoot

Reputation: 142710

Looks like SQL*Plus.

SQL> create table var (variable_value number, loc varchar2(5), atom varchar2(5), variable_name varchar2(10));

Table created.

SQL> set ver off
SQL>
SQL> column set_schema_pow new_value schema_pow
SQL>
SQL> select variable_value set_schema_pow
  2  from &schema..var
  3  where
  4  loc = 'PROD'
  5  and atom = '&vta'
  6  and variable_name = 'schema_pow';
Enter value for schema: scott
Enter value for vta: a

no rows selected

SQL>

Or even this (with some data stored into a table):

SQL> insert into var values (100, 'PROD', 'a', 'schema_pow');

1 row created.

SQL> column set_schema_pow new_value schema_pow
SQL>
SQL> select variable_value set_schema_pow
  2  from &schema..var
  3  where
  4  loc = 'PROD'
  5  and atom = '&vta'
  6  and variable_name = 'schema_pow';
Enter value for schema: scott
Enter value for vta: a

SET_SCHEMA_POW
--------------
           100

SQL>

Upvotes: 2

Related Questions