Convert Product to Product master

Changing the table inheritance of a record must be done on SQL level – the following code does this. Of course, related data must be handled as well.

static void Job1(Args _args)
    //change to product master
    //change back
//Important: this code must be run on the server
public static server void changeInheritance(str _tableName, tableId _newTableId, RefRecId   _refRecId)
    Connection      connection;
    Statement       statement;
    str             query;
    // create connection object
    connection = new Connection();
    // create statement
    statement = connection.createStatement();
    // Set the SQL statement
    query = strfmt("update %1 set %1.InstanceRelationType ='%2' where %1.RecId = %3;", _tableName, _newTableId, _refRecId);
    // assert SQL statement execute permission
    new SqlStatementExecutePermission(query).assert();
    //BP Deviation documented
    // limit the scope of the assert call