The command 'new_value' for SQLPlus

Format:

column column_name new_value var_name

Meaning:

use the column_name of a select statment to construct a variable, later we can use &var_name to refer its value.

If the Select statement returned more that one row, the last row value will be assigned  to the variable.

 Example 1:

-- create directory and varchar2 array
col value new_value user_dump_directory;
select value from v$parameter where name = ‘user_dump_dest‘;
create or replace directory user_dump_dir as ‘&user_dump_directory‘;

Example 2
set feedback off
set verify off

create table new_value_test_from (
  some_field_name Varchar2(20)
);

create table new_value_test_to (
  another_field Varchar2(20)
);
insert into new_value_test_from values (‘Maegerli Mucki‘); column some_field_name new_value some_var_name select some_field_name from new_value_test_from; insert into new_value_test_to values (‘&some_var_name‘); select * from new_value_test_to; drop table new_value_test_from; drop table new_value_test_to;
set feedback off
set verify off

create table new_value_test (
  some_field_name Varchar2(20)
);

Example 3
insert into new_value_test values (‘Maegerli Mucki‘); insert into new_value_test values (‘Globi‘); column some_field_name new_value some_var_name select some_field_name from new_value_test; drop table new_value_test;

The command 'new_value' for SQLPlus,布布扣,bubuko.com

The command 'new_value' for SQLPlus

上一篇:Oracle游标-循环查询表中数据(表名),并执行


下一篇:Oracle定时器调用存储过程