Guideline For Using DbPoolConnector Incodelist SI Maps

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

Pre-session Extended Rule:

// Declare the connector object


Object connector;

// Create the connector


connector = new("com.stercomm.emea.mstrombrink.dbpoolconnector.Connector");

// debugInfoMapName must be assigned name of current map!


connector.debugInfoMapName("Name of the map");

// doDebug must be enabled to create a debug log in noapp.log!


connector.doDebug();

// Connect to a database pool


// N.B.: Remember to disconnect in Post-session!
connector.connect("DSV_PARTNER_EDI_CONF");

Post-session Extended Rule:


// Disconnect from database
connector.disconnect();

Example use of DbPoolConnector in Extended Rule for incrementing Control Numbers:


string[512] tmp_sql;
string[15] ctrl_num_str, ctrl_num_str_pad;
integer ctrl_num;

// Start Transaction
connector.transactionStart();

// Get CONTROL_NUMBER_VALUE from the table DSV_ControlNumber_tb and lock for


update
tmp_sql="SELECT CONTROL_NUMBER_VALUE FROM DSV_ControlNumber_tb WHERE
CONTROL_NUMBER_NAME= 'Name of Control Number' FOR UPDATE";
ctrl_num=connector.getResultAsIntegerExistingConn(tmp_sql,"CONTROL_NUMBER_VAL
UE");

// Check for value greater than 9999999, if so reset to 1, else increment


If ctrl_num > 9999999 then
ctrl_num = 1 ;
else
ctrl_num = ctrl_num + 1;

// Convert Integer to string


ntoa(ctrl_num, ctrl_num_str);

// UPDATE the table with new value


tmp_sql="UPDATE DSV_ControlNumber_tb SET CONTROL_NUMBER_VALUE = " +
ctrl_num_str +" WHERE CONTROL_NUMBER_NAME= 'Name of Control Number'";
connector.statementPrepare(tmp_sql);
connector.statementExecuteUpdate();

// Commit and thereby also release lock


connector.transactionCommit();

// Make sure that that the control number have a length of 7 characters
ctrl_num_str_pad = "000000" + ctrl_num_str;
ctrl_num_str = right(ctrl_num_str_pad, 7);

Name of control Number should be either: DSV_PartnerCode_MessageType_ctl (If used for only one
message type) or DSV_PartnerCode_GLOBAL_ctl (If used for multiple message types).

You might also like