#-----Reorganize the table --------------------------------------------------

$status=`perl /usr/local/hp/nvscript/bin/hpnvs.pl "$reorgtable"`; print "Reorg status :".$status;

print "\n";

#----------Update the statistics of the table--------------------------------

$status=`perl /usr/local/hp/nvscript/bin/hpnvs.pl "$updatestats"`; print "Update statistics status :".$status;

print "\n";

#

--------------Fetch results-------------------------------------------------

@resultrows=`perl /usr/local/hp/nvscript/bin/hpnvs.pl "$selecttable"`;

#

-------------Display the results--------------------------------------------

foreach $rowvalue (@resultrows)

{

 

 

print $rowvalue;

}

 

Example of a Python Program (example.py)

import os import sys import string

if __name__ == '__main__':

#Define SQL statements

reorgtable="REORG TABLE neo.persnl.employee"; updatestats="UPDATE STATISTICS FOR TABLE neo.persnl.employee " updatestats=updatestats + "ON EVERY COLUMN"; selecttable="SELECT COUNT(*) FROM neo.persnl.employee";

#Contruct a list of SQL statements to be executed stmnt = [reorgtable,updatestats,selecttable] print "\n";

for stmntstr in stmnt:

cin, cout ,cerr = os.popen3('python /usr/local/hp/nvscript/bin/hpnvs.py "'+stmntstr+'"')

while 1:

text = cout.read() if text:

print text else:

break

while 1:

text = cerr.read() if text:

print text else:

break

cin.close()

cout.close()

Running the Perl or Python Program

Before running the Perl or Python program, make sure that you included the absolute path of the Perl or Python wrapper script (hpnvs.pl or hpnvs.py) in the program file:

On Windows: hpnvs-installation-directory\nvscript\bin\hpnvs.plor hpnvs-installation-directory\nvscript\bin\hpnvs.py

hpnvs-installation-directoryis the directory where you installed the Neoview Script software files. For more information, see Table 2-1 (page 34).

On Linux or UNIX: hpnvs-installation-directory/nvscript/bin/hpnvs.plor hpnvs-installation-directory/nvscript/bin/hpnvs.py

Launching Neoview Script From a Perl or Python Program 77