Set up a user session
Log on to the database instance
Create a table and query error code
Use
# Reference to SAP DB Perl Library
# -------------------------------
use SAP::DBTECH::repman;
#
Parse the call arguments# --------------------------
$user = $ARGV[0];
$pwd = $ARGV[1];
$dbname = $ARGV[2];
$data_path = $ARGV[3];
$host = "localhost";
# Start a user session with the REPMServer
# -------------------------------------------
$session = repman::RepMan ($host, $dbname);
# Log on to the database instance
# --------------------------------
$session->cmd("use user $user $pwd;");
$rc = $session->sql('EXISTS TABLE CUSTOMER')
If $rc!=0
# Create the table CUSTOMER
# -------------------------
$session->cmd ( 'CREATE TABLE customer ( '.
'cno FIXED(4), '.
'surname CHAR(10) ASCII, '.
'zip CHAR(5) ASCII, '.
'place CHAR(12) ASCII, '.
'PRIMARY KEY (cno) ')
print $rc
If $rc==0
# Then branch of the If statement must be indented in Python
# Load table CUSTOMER
# ----------------------------------------------------------
$loadrc = $session->cmd ("DATALOAD TABLE customer ".
"cno 1-4".
"surname 6-12".
"zip 14-18".
"place 20-31".
"INFILE $data_path\customer.dat" )
print $loadrc
# End the database session
# ----------------------------
undef $session