Example #1
0
int OraDBRequest::processShampooBind()
{
    const char sql_stmt[] = "BEGIN"
        " SP_PROCESS_SHAMPOO(:p_retr, :p_type, :p_msisdn, :p_plan, :p_start, :p_end);"
        " END;";

    _sth_process_shampoo = SQLO_STH_INIT;

    if ((_sth_process_shampoo = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SP_PROCESS_SHAMPOO.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_process_shampoo, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0)
                || sqlo_bind_by_name(_sth_process_shampoo, ":p_type", SQLOT_STR, &_request.svc_type, sizeof(_request.svc_type), 0, 0)
                || sqlo_bind_by_name(_sth_process_shampoo, ":p_msisdn", SQLOT_STR, &_request.svc_msisdn, sizeof(_request.svc_msisdn), 0, 0)
                || sqlo_bind_by_name(_sth_process_shampoo, ":p_plan", SQLOT_STR, &_request.svc_plan, sizeof(_request.svc_plan), 0, 0)
                || sqlo_bind_by_name(_sth_process_shampoo, ":p_start", SQLOT_STR, &_request.svc_start, sizeof(_request.svc_start), 0, 0)
                || sqlo_bind_by_name(_sth_process_shampoo, ":p_end", SQLOT_STR, &_request.svc_end, sizeof(_request.svc_end), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SP_PROCESS_SHAMPOO statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #2
0
int OraDBRequest::selectConditionerBind()
{
    const char sql_stmt[] = "select id, tran_type, msisdn, promo_code, promo_value, promo_name, service_id, cluster_node, brand"
        " from conditioner_log where brand = :brand and cluster_node = :cluster_node and status = :status"
        " and rownum < :limit order by id";

    _sth_select_conditioner = SQLO_STH_INIT;

    if ((_sth_select_conditioner = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SELECT_CONDITIONER.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                   sqlo_bind_by_name(_sth_select_conditioner, ":brand", SQLOT_STR, &_var_brand, sizeof(_var_brand), 0, 0)
                || sqlo_bind_by_name(_sth_select_conditioner, ":cluster_node", SQLOT_INT, &_var_cluster_node, sizeof(_var_cluster_node), 0, 0)
                || sqlo_bind_by_name(_sth_select_conditioner, ":status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0)
                || sqlo_bind_by_name(_sth_select_conditioner, ":limit", SQLOT_INT, &_var_limit, sizeof(_var_limit), 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 1, SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 2, SQLOT_INT, &_request.tran_type, sizeof(_request.tran_type), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 3, SQLOT_STR, &_request.a_no, sizeof(_request.a_no), &_ind_a_no, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 4, SQLOT_STR, &_request.promo_code, sizeof(_request.promo_code), &_ind_promo_code, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 5, SQLOT_STR, &_request.promo_value, sizeof(_request.promo_value), &_ind_promo_value, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 6, SQLOT_STR, &_request.promo_name, sizeof(_request.promo_name), &_ind_promo_name, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 7, SQLOT_STR, &_request.service_id, sizeof(_request.service_id), &_ind_service_id, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 8, SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select_conditioner, 9, SQLOT_STR, &_request.brand, sizeof(_request.brand), &_ind_brand, 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SELECT_CONDITIONER statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #3
0
int OraDBRequest::usurfActivationBind()
{
    const char sql_stmt[] = "BEGIN"
        " SP_USURF_ACTIVATION(:p_retr, :p_partner, :p_exptime, :p_expdate, :p_msisdn, :p_country, :p_duration, :p_nf_status);"
        " END;";

    _sth_ua = SQLO_STH_INIT;

    if ((_sth_ua = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SP_USURF_ACTIVATION.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_ua, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_partner", SQLOT_STR, &_var_extra_o_1, sizeof(_var_extra_o_1), &_ind_extra_1, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_exptime", SQLOT_STR, &_var_extra_o_2, sizeof(_var_extra_o_2), &_ind_extra_2, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_expdate", SQLOT_STR, &_var_extra_o_3, sizeof(_var_extra_o_3), &_ind_extra_3, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_msisdn", SQLOT_STR, &_var_msisdn, sizeof(_var_msisdn), 0, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_country", SQLOT_STR, &_var_country, sizeof(_var_country), 0, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_duration", SQLOT_INT, &_var_duration, sizeof(_var_duration), 0, 0)
                || sqlo_bind_by_name(_sth_ua, ":p_nf_status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SP_USURF_ACTIVATION statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #4
0
int OraDBRequest::processMlpBind()
{
    const char sql_stmt[] = "BEGIN"
        " SP_PROCESS_MLP(:p_retr, :p_msisdn, :p_transaction_code, :p_transaction_id, :p_bill_cycle, :p_type, :p_soc, :p_effdate);"
        " END;";

    _sth_process_mlp = SQLO_STH_INIT;

    if ((_sth_process_mlp = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SP_PROCESS_MLP.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_process_mlp, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_msisdn", SQLOT_STR, &_request.svc_msisdn, sizeof(_request.svc_msisdn), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_transaction_code", SQLOT_STR, &_request.svc_txcode, sizeof(_request.svc_txcode), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_transaction_id", SQLOT_STR, &_request.svc_txid, sizeof(_request.svc_txid), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_bill_cycle", SQLOT_STR, &_request.svc_bill_cycle, sizeof(_request.svc_bill_cycle), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_type", SQLOT_STR, &_request.svc_type, sizeof(_request.svc_type), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_soc", SQLOT_STR, &_request.svc_soc, sizeof(_request.svc_soc), 0, 0)
                || sqlo_bind_by_name(_sth_process_mlp, ":p_effdate", SQLOT_STR, &_request.svc_eff_date, sizeof(_request.svc_eff_date), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SP_PROCESS_MLP statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #5
0
int OraDBRequest::selectManualBind()
{
    //-- ACTIVATION, DEACTIVATION, EXTENSION, CANCEL
    const char sql_stmt[] = "select id, msisdn, enrollment_type, cluster_node, customer_type, link_to, silent, request_origin, imsi"
        " from manual_enrollment_log where tx_date <= sysdate"
        " and cluster_node = :cluster_node and status = :status"
        " and rownum < :limit order by id";

    _sth_select2 = SQLO_STH_INIT;

    if ((_sth_select2 = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SELECT_MANUAL_REQUEST.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_select2, ":cluster_node", SQLOT_INT, &_var_cluster_node, sizeof(_var_cluster_node), 0, 0)
                || sqlo_bind_by_name(_sth_select2, ":status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0)
                || sqlo_bind_by_name(_sth_select2, ":limit", SQLOT_INT, &_var_limit, sizeof(_var_limit), 0, 0)
                || sqlo_define_by_pos(_sth_select2,  1, SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  2, SQLOT_STR, &_request.a_no, sizeof(_request.a_no), &_ind_a_no, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  3, SQLOT_STR, &_request.msg, sizeof(_request.msg), &_ind_msg, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  4, SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  5, SQLOT_STR, &_request.customer_type, sizeof(_request.customer_type), &_ind_customer_type, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  6, SQLOT_STR, &_request.gsm_num, sizeof(_request.gsm_num), &_ind_gsm_num, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  7, SQLOT_INT, &_request.silent, sizeof(_request.silent), &_ind_silent, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  8, SQLOT_STR, &_request.request_origin, sizeof(_request.request_origin), &_ind_request_origin, 0, 0)
                || sqlo_define_by_pos(_sth_select2,  9, SQLOT_STR, &_request.imsi, sizeof(_request.imsi), &_ind_imsi, 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SELECT_MANUAL_REQUEST statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #6
0
int OraDBRequest::processTranBind()
{
    const char sql_stmt[] = "BEGIN"
        " SP_PROCESS_TRAN(:p_retr, :p_extra_o_1, :p_extra_o_2, :p_extra_o_3,"
        " :p_trantype, :p_msisdn, :p_req_id, :p_ref_id, :p_extra_i_1, :p_extra_i_2, :p_extra_i_3);"
        " END;";

    _sth_pt = SQLO_STH_INIT;

    if ((_sth_pt = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SP_PROCESS_TRAN.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_pt, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_extra_o_1", SQLOT_STR, &_var_extra_o_1, sizeof(_var_extra_o_1), &_ind_extra_1, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_extra_o_2", SQLOT_STR, &_var_extra_o_2, sizeof(_var_extra_o_2), &_ind_extra_2, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_extra_o_3", SQLOT_STR, &_var_extra_o_3, sizeof(_var_extra_o_3), &_ind_extra_3, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_trantype", SQLOT_INT, &_var_trantype, sizeof(_var_trantype), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_msisdn", SQLOT_STR, &_var_msisdn, sizeof(_var_msisdn), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_req_id", SQLOT_INT, &_var_req_id, sizeof(_var_req_id), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_ref_id", SQLOT_INT, &_var_ref_id, sizeof(_var_ref_id), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_extra_i_1", SQLOT_STR, &_var_extra_i_1, sizeof(_var_extra_i_1), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_extra_i_2", SQLOT_STR, &_var_extra_i_2, sizeof(_var_extra_i_2), 0, 0)
                || sqlo_bind_by_name(_sth_pt, ":p_extra_i_3", SQLOT_STR, &_var_extra_i_3, sizeof(_var_extra_i_3), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SP_PROCESS_TRAN statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #7
0
int select2(struct libdb *dbp, struct rdset *rdsetp, const char *qcmd)
{
	if (!is_open(dbp) && !open(dbp))
	{
		return 0;
	}
	rdsetp->rd_db_type = dbp->db_type;
	int result = 0;
	const int type = dbp->db_type;
	switch (type)
	{
	case DB_ORACLE:
		{
			int ret = -1;
			if (NULL == rdsetp->rd_orap)
			{
				rdsetp->rd_orap = (rdset_oracle *)malloc(sizeof(struct rdset_oracle));
			}
			ret = sqlo_prepare(rdsetp->rd_orap->rd_orap, qcmd);
			if (ret < 0)
			{
				result = 0;
				set_error_d(dbp, "sqlo_prepare");
				break;
			}
		}
		break;
	case DB_MYSQL:
		{
			int ret = -1;
			ret = mysql_real_query(dbp->db_sqlp->mys_sqlp, qcmd, strlen(qcmd));
			if (0 != ret)
			{
				result = 0;
				set_error_d(dbp, "mysql_query");
				break;
			}
			if (NULL == rdsetp->rd_mysqlp)
				rdsetp->rd_mysqlp = (rdset_mysql *)malloc(sizeof(struct rdset_mysql));

			rdsetp->rd_mysqlp->rd_resp = mysql_store_result(dbp->db_sqlp->mys_sqlp);
			if (NULL == rdsetp->rd_mysqlp->rd_resp)
			{
				result = 0;
				set_error_d(dbp, "mysql_store_result");
				break;
			}
		}
		break;
	default:
		{
			result = 0;
			set_error_d(dbp, "the database type is not supported");
		}
		break;
	}
	return 0;
}
Example #8
0
int OraDBRequest::selectBind()
{
    const char sql_stmt[] = "select id, msg, a_no, b_no, step_no, last_step_no"
        ", tran_type, cluster_node, customer_type, request_origin, ref_id, imsi"
        ", activation_date, deactivation_date, duration, gsm_num, result_code, silent"
        ", nsn_flag, brand from request_log"
        " where tran_dt > trunc(sysdate-3) and brand = :brand and cluster_node = :cluster_node and step_no = :step_no and status = :status"
        " and rownum < :limit order by id";

    _sth_select = SQLO_STH_INIT;

    if ((_sth_select = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SELECT_REQUEST.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                   sqlo_bind_by_name(_sth_select, ":brand", SQLOT_STR, &_var_brand, sizeof(_var_brand), 0, 0)
                || sqlo_bind_by_name(_sth_select, ":cluster_node", SQLOT_INT, &_var_cluster_node, sizeof(_var_cluster_node), 0, 0)
                || sqlo_bind_by_name(_sth_select, ":step_no", SQLOT_INT, &_var_step_no, sizeof(_var_step_no), 0, 0)
                || sqlo_bind_by_name(_sth_select, ":status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0)
                || sqlo_bind_by_name(_sth_select, ":limit", SQLOT_INT, &_var_limit, sizeof(_var_limit), 0, 0)
                || sqlo_define_by_pos(_sth_select,  1, SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select,  2, SQLOT_STR, &_request.msg, sizeof(_request.msg), &_ind_msg, 0, 0)
                || sqlo_define_by_pos(_sth_select,  3, SQLOT_STR, &_request.a_no, sizeof(_request.a_no), &_ind_a_no, 0, 0)
                || sqlo_define_by_pos(_sth_select,  4, SQLOT_STR, &_request.b_no, sizeof(_request.b_no), &_ind_b_no, 0, 0)
                || sqlo_define_by_pos(_sth_select,  5, SQLOT_INT, &_request.step_no, sizeof(_request.step_no), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select,  6, SQLOT_INT, &_request.last_step_no, sizeof(_request.last_step_no), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select,  7, SQLOT_INT, &_request.tran_type, sizeof(_request.tran_type), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select,  8, SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select,  9, SQLOT_STR, &_request.customer_type, sizeof(_request.customer_type), &_ind_customer_type, 0, 0)
                || sqlo_define_by_pos(_sth_select, 10, SQLOT_STR, &_request.request_origin, sizeof(_request.request_origin), &_ind_request_origin, 0, 0)
                || sqlo_define_by_pos(_sth_select, 11, SQLOT_INT, &_request.ref_id, sizeof(_request.ref_id), 0, 0, 0)
                || sqlo_define_by_pos(_sth_select, 12, SQLOT_STR, &_request.imsi, sizeof(_request.imsi), &_ind_imsi, 0, 0)
                || sqlo_define_by_pos(_sth_select, 13, SQLOT_STR, &_request.activation_date, sizeof(_request.activation_date), &_ind_activation_date, 0, 0)
                || sqlo_define_by_pos(_sth_select, 14, SQLOT_STR, &_request.deactivation_date, sizeof(_request.deactivation_date), &_ind_deactivation_date, 0, 0)
                || sqlo_define_by_pos(_sth_select, 15, SQLOT_INT, &_request.duration, sizeof(_request.duration), &_ind_duration, 0, 0)
                || sqlo_define_by_pos(_sth_select, 16, SQLOT_STR, &_request.gsm_num, sizeof(_request.gsm_num), &_ind_gsm_num, 0, 0)
                || sqlo_define_by_pos(_sth_select, 17, SQLOT_INT, &_request.result_code, sizeof(_request.result_code), &_ind_result_code, 0, 0)
                || sqlo_define_by_pos(_sth_select, 18, SQLOT_INT, &_request.silent, sizeof(_request.silent), &_ind_silent, 0, 0)
                || sqlo_define_by_pos(_sth_select, 19, SQLOT_INT, &_request.nsn_flag, sizeof(_request.nsn_flag), &_ind_nsn_flag, 0, 0)
                || sqlo_define_by_pos(_sth_select, 20, SQLOT_STR, &_request.brand, sizeof(_request.brand), &_ind_brand, 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SELECT_REQUEST statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #9
0
int OraDBRequest::updateBind()
{
    const char sql_stmt[] = "update request_log set step_no = :step_no, last_step_no = :last_step_no"
        ", status = :status, tran_type = :tran_type, customer_type = :customer_type, min_bal = :min_bal"
        ", error_code = :error_code, imsi = :imsi"
        ", activation_date = :activation_date, deactivation_date = :deactivation_date, duration = :duration"
        ", gsm_num = :gsm_num, result_code = :result_code, silent = :silent, nsn_flag = :nsn_flag"
        ", dt_modified = sysdate where id = :id";

    _sth_update = SQLO_STH_INIT;

    if ((_sth_update = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for UPDATE_REQUEST.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_update, ":id", SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":step_no", SQLOT_INT, &_request.step_no, sizeof(_request.step_no), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":last_step_no", SQLOT_INT, &_request.last_step_no, sizeof(_request.last_step_no), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":status", SQLOT_INT, &_request.status, sizeof(_request.status), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":tran_type", SQLOT_INT, &_request.tran_type, sizeof(_request.tran_type), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":customer_type", SQLOT_STR, &_request.customer_type, sizeof(_request.customer_type), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":min_bal", SQLOT_INT, &_request.min_bal, sizeof(_request.min_bal), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":error_code", SQLOT_INT, &_request.error_code, sizeof(_request.error_code), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":imsi", SQLOT_STR, &_request.imsi, sizeof(_request.imsi), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":activation_date", SQLOT_STR, &_request.activation_date, sizeof(_request.activation_date), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":deactivation_date", SQLOT_STR, &_request.deactivation_date, sizeof(_request.deactivation_date), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":duration", SQLOT_INT, &_request.duration, sizeof(_request.duration), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":gsm_num", SQLOT_STR, &_request.gsm_num, sizeof(_request.gsm_num), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":result_code", SQLOT_INT, &_request.result_code, sizeof(_request.result_code), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":silent", SQLOT_INT, &_request.silent, sizeof(_request.silent), 0, 0)
                || sqlo_bind_by_name(_sth_update, ":nsn_flag", SQLOT_INT, &_request.nsn_flag, sizeof(_request.nsn_flag), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for UPDATE_REQUEST statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #10
0
int OraDBRequest::updateManualBind()
{
    const char sql_stmt[] = "update manual_enrollment_log set"
        " status = :status, dt_modified = sysdate where id = :id";

    _sth_update2 = SQLO_STH_INIT;

    if ((_sth_update2 = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for UPDATE_MANUAL_REQUEST.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_update2, ":id", SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0)
                || sqlo_bind_by_name(_sth_update2, ":status", SQLOT_INT, &_request.status, sizeof(_request.status), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for UPDATE_MANUAL_REQUEST statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #11
0
int OraDBRequest::updateConditionerBind()
{
    const char sql_stmt[] = "update conditioner_log set"
        " status = :status, dt_modified = sysdate where id = :id";

    _sth_update_conditioner = SQLO_STH_INIT;

    if ((_sth_update_conditioner = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for UPDATE_CONDITIONER.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_update_conditioner, ":id", SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0)
                || sqlo_bind_by_name(_sth_update_conditioner, ":status", SQLOT_INT, &_request.status, sizeof(_request.status), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for UPDATE_CONDITIONER statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #12
0
int OraDBRequest::insertKeywordBind()
{
    const char sql_stmt[] = "insert into keywordRequest (id, ref_id, msisdn, imsi, enrollment_type, start_tm)"
        " values (keywordRequest_id_seq.nextval, :ref_id, :msisdn, :imsi, :enrollment_type, sysdate)";

    _sth_insert_kw = SQLO_STH_INIT;

    if ((_sth_insert_kw = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for INSERT_KEYWORD_REQUEST.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                   sqlo_bind_by_name(_sth_insert_kw, ":ref_id", SQLOT_INT, &_request.ref_id, sizeof(_request.ref_id), 0, 0)
                || sqlo_bind_by_name(_sth_insert_kw, ":msisdn", SQLOT_STR, &_request.a_no, sizeof(_request.a_no), 0, 0)
                || sqlo_bind_by_name(_sth_insert_kw, ":imsi", SQLOT_STR, &_request.imsi, sizeof(_request.imsi), 0, 0)
                || sqlo_bind_by_name(_sth_insert_kw, ":enrollment_type", SQLOT_STR, &_request.msg, sizeof(_request.msg), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for INSERT_KEYWORD_REQUEST statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #13
0
int OraDBRequest::usurfDeactivationBind()
{
    const char sql_stmt[] = "BEGIN"
        " SP_USURF_DEACTIVATION(:p_retr, :p_msisdn, :p_service_id);"
        " END;";

    _sth_ud = SQLO_STH_INIT;

    if ((_sth_ud = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for SP_USURF_DEACTIVATION.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_ud, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0)
                || sqlo_bind_by_name(_sth_ud, ":p_msisdn", SQLOT_STR, &_var_msisdn, sizeof(_var_msisdn), 0, 0)
                || sqlo_bind_by_name(_sth_ud, ":p_service_id", SQLOT_STR, &_var_service_id, sizeof(_var_service_id), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for SP_USURF_DEACTIVATION statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #14
0
int OraDBRequest::insertBind()
{
    const char sql_stmt[] = "insert into request_log (id, txid, msg, a_no, b_no"
        ", tran_type, cluster_node, customer_type, request_origin, ref_id, gsm_num, silent, imsi"
        ", dt_created, tran_dt)"
        " values (request_log_seq.nextval, :txid, :msg, :a_no, :b_no"
        ", :tran_type, :cluster_node, :customer_type, :request_origin, :ref_id, :gsm_num, :silent, :imsi"
        ", sysdate, trunc(sysdate))";

    _sth_insert = SQLO_STH_INIT;

    if ((_sth_insert = sqlo_prepare(_dbh, sql_stmt)) < 0) {
        LOG_CRITICAL("%s: Failed to prepare statement handle for INSERT_REQUEST.", __func__);
        return -1;
    }

    if (SQLO_SUCCESS != (
                sqlo_bind_by_name(_sth_insert, ":txid", SQLOT_STR, &_request.txid, sizeof(_request.txid), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":msg", SQLOT_STR, &_request.msg, sizeof(_request.msg), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":a_no", SQLOT_STR, &_request.a_no, sizeof(_request.a_no), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":b_no", SQLOT_STR, &_request.b_no, sizeof(_request.b_no), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":tran_type", SQLOT_INT, &_request.tran_type, sizeof(_request.tran_type), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":cluster_node", SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":customer_type", SQLOT_STR, &_request.customer_type, sizeof(_request.customer_type), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":request_origin", SQLOT_STR, &_request.request_origin, sizeof(_request.request_origin), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":ref_id", SQLOT_INT, &_request.ref_id, sizeof(_request.ref_id), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":gsm_num", SQLOT_STR, &_request.gsm_num, sizeof(_request.gsm_num), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":silent", SQLOT_INT, &_request.silent, sizeof(_request.silent), 0, 0)
                || sqlo_bind_by_name(_sth_insert, ":imsi", SQLOT_STR, &_request.imsi, sizeof(_request.imsi), 0, 0)
                )) {
        LOG_CRITICAL("%s: Failed to bind variables for INSERT_REQUEST statement handle.", __func__);
        return -2;
    }

    return 0;
}
Example #15
0
int execute(struct libdb *dbp, const char *qcmd)
{
	if (!is_open(dbp) && !open(dbp))
	{
		return 0;
	}
	int result = 0;
	switch (dbp->db_type)
	{
	case DB_ORACLE:
		{
			int ret;
			ret = sqlo_prepare(dbp->db_orap->ora_dbhp, qcmd);
			if (ret < 0)
			{
				set_error_d(dbp, "sqlo_prepare");
				result = 0;
				break;
			}
			void *param_addr = NULL;
			ret = sqlo_bind_by_name(dbp->db_orap->ora_dbhp, ":1", SQLOT_STR, param_addr, 64, NULL, 0);
			if (SQLO_SUCCESS != ret)
			{
				set_error_d(dbp, "sqlo_bind_by_name");
				result = 0;
				break;
			}
			ret = sqlo_execute(dbp->db_orap->ora_dbhp, 1);
			if (SQLO_SUCCESS != ret)
			{
				set_error_d(dbp, "sqlo_execute");
				result = 0;
				break;
			}
			ret = sqlo_commit(dbp->db_orap->ora_dbhp);
			if (SQLO_SUCCESS != ret)
			{
				sqlo_rollback(dbp->db_orap->ora_dbhp);
				result = 0;
				break;
			}
			result = 1;
		}
		break;
	case DB_MYSQL:
		{
			MYSQL_RES *tmp = NULL;
			int ret = -1;
			unsigned long len = strlen(qcmd);
			ret = mysql_real_query(dbp->db_sqlp->mys_sqlp, qcmd, len);
			if (0 != ret)
			{
				result = 0;
				set_error_d(dbp, "mysql_query");
				break;
			}
			//Although needs no results, but still need to call the following two API function
			tmp = mysql_use_result(dbp->db_sqlp->mys_sqlp);
			if (NULL == tmp)
			{
				result = 0;
				set_error_d(dbp, "mysql_use_result");
				break;
			}
			mysql_free_result(tmp);
			ret = mysql_commit(dbp->db_sqlp->mys_sqlp);
			if (0 != ret)
			{
				result = 0;
				mysql_rollback(dbp->db_sqlp->mys_sqlp);
			}
			tmp = NULL;
			result = 1;
		}
		break;
	default:
		{
			result = 0;
			set_error_d(dbp,"the database type is not supported");
		}
		break;
	}
	return result;
}