Skip to content

Using COLUMN in SQL*Plus

Here’s something I learned about SQL*Plus today. If you want to create a variable in a script, you can use the COLUMN command. In the following script, 2 variables called HOST_NAME and DATABASE_NAME are created. Their values are filled in when the SELECT statement executes.

   col host_name new_value HOST_NAME
   col instance_name new_value DATABASE_NAME
 
   SELECT host_name, instance_name  FROM v$instance;
 
   UPDATE TABLE SET VALUE = '&&HOST_NAME'

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*