Where do you run these statements from? Is it an X-Cart 5 module? Or is it a custom stand-alone script?
If it is a stand-alone script, did you include all required files as follows?
Code:
...
try {
define('LC_INCLUDE_ADDITIONAL', true);
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'top.inc.php');
// your statements there
} catch (\Exception $e) {
\Includes\ErrorHandler::handleException($e);
}