Neoview Command Interface (NCI) Guide (R2.3)
The command returns this output:
EMPNUM FIRST_NAME LAST_NAME DEPTNUM JOBCODE SALARY
------ --------------- -------------- ------- ------- --------
1 ROGER GREEN 9000 100 175500.00
23 JERRY HOWARD 1000 100 137000.10
29 JANE RAYMOND 3000 100 136000.00
32 THOMAS RUDLOFF 2000 100 138000.40
...
--- 61 row(s) selected.
Launching NCI From a Perl or Python Program
You can execute an SQL statement by invoking the NCI Perl or Python wrapper script in a Perl
or Python program. You can pass only one SQL statement at a time in a perl or python
command. To execute an SQL statement in a Perl or Python program, follow these instructions:
• “Setting the Login Environment Variables” (page 86)
• “Using SQL Statements in a Perl or Python Program” (page 86)
• “Running the Perl or Python Program” (page 87)
Setting the Login Environment Variables
To invoke the Perl or Python wrapper script in a Perl or Python program, you must set the login
environment variables. For more information, see “Setting the Login Environment Variables”
(page 81).
Using SQL Statements in a Perl or Python Program
In a Perl or Python program, each SQL statement that you invoke with the Perl or Python wrapper
script must:
• Be enclosed in double quotes (") without the SQL terminator (;)
• Contain fully qualified database object names (for example, neo.schema-name.obj-name)
• Contain the syntax of one of the supported SQL statements. See Appendix B (page 155).
For examples, see “Example of a Perl Program (example.pl)” (page 86) and “Example of a Python
Program (example.py)” (page 87).
Example of a Perl Program (example.pl)
#########################################################################
# Example Perl program that maintains a database using hpnci.pl #
#########################################################################
#----------------------------------------------------------------------------
$reorgtable="REORG TABLE neo.persnl.employee";
$updatestats="UPDATE STATISTICS FOR TABLE neo.persnl.employee ".
"ON EVERY COLUMN";
$selecttable="SELECT COUNT(*) FROM neo.persnl.employee";
print "\n";
#-----Reorganize the table --------------------------------------------------
$status=`perl /usr/local/hp/nci/bin/hpnci.pl "$reorgtable"`;
print "Reorg status :".$status;
print "\n";
#----------Update the statistics of the table--------------------------------
$status=`perl /usr/local/hp/nci/bin/hpnci.pl "$updatestats"`;
print "Update statistics status :".$status;
print "\n";
#--------------Fetch results-------------------------------------------------
@resultrows=`perl /usr/local/hp/nci/bin/hpnci.pl "$selecttable"`;
86 Running NCI From Perl or Python