The Oracle (tm) Users' Co-Operative FAQ

Is it possible to return a set of results from SQL*Plus to a UNIX variable ?


Author's name: Raj Sakthi

Author's Email: raj_sakthi@yahoo.com

Date written: 9th Aug 2001

Oracle version(s): 8.1.7

Is it possible to return a set of results from SQL*Plus to a UNIX variable ?

Back to index of questions


One possible method is shown below:

	*********sh script **************
	#!/bin/sh
	var="set pagesize 0
	select * from v\$instance;"
	nad=$(print "$var" | sqlplus -s internal)
	echo $nad
	*********** end **************

The output is like this

	############# OUTPUT #####################
	sdev_ora@stxdev  [/dev_ora/home/dev_ora/scripts]
	$ ./raj_test.sh 
	1 stxqa stxdev 8.1.7.1.0 07-AUG-2001 OPEN NO 1 STOPPED
	ALLOWED NO ACTIVE PRIMARY_INSTANCE
	
	sdev_ora@stxdev  [/dev_ora/home/dev_ora/scripts]
	#################  END  ####################

Further reading: N/A


Back to top

Back to index of questions