Example of Calling the Loader with Perl Script
Start
a database session,
Log on to the database instance,
Query error code to determine whether table exists
Create a table without querying the error code
Log off
# Reference to the Perl Library
# -------------------------------
use SAP::DBTECH::loader;
# Parse the call arguments
# --------------------------
$user_name = $ARGV[0];
$password = $ARGV[1];
$database_name = $ARGV[2];
$data_path = $ARGV[3];
$server_node = "localhost";
# Create a database session for the Loader
# -------------------------------------------
$session = loader::Loader ($server_node, $database_name);
# Log on to the database instance
# --------------------------------
$session->cmd("use user $user_name $password;");
# Query whether the table exists by querying the error code
# The sql method is used to do this
# -------------------------------------
$rc = $session->sql('EXISTS TABLE CUSTOMER')
If $rc!=0
# Create the table CUSTOMER
# -------------------------
$session->cmd ( 'CREATE TABLE customer ( '.
'cno FIXED(4),
'.
'name CHAR(10)
ASCII, '.
'zip CHAR(5) ASCII, '.
'city CHAR(12)
ASCII, '.
'PRIMARY
KEY (cno) ')
# End the database session
# ----------------------------
undef $session