Perl: Example No. 3 

Set up a user session
Log on to the database instance
Query whether table exists by querying the error code
Create a table without querying error code
Log off

 

# 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

# -------------------------

$s# Create the table CUSTOMER

# ---------------------$session->cmd ( 'CREATE TABLE customer ( '.

   # End the database session

# ----------------------------

undef $session

 

 

undef $session <undef $session