sqlite3_exrc执行select回调次数

本文介绍了一个使用FreeSWITCH查询坐席状态的示例程序。该程序通过SQLite数据库读取坐席信息,并演示了如何在查询过程中使用回调函数来控制查询流程。回调函数返回0将继续查询下一条记录,返回1将停止查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在freeswitch中,查询坐席的时候,当place_call_ringall_callback返回0 则继续下一条的回调,当返回1则停止回调
#include <iostream>
using namespace std;
#include <sqlite3.h>
int callback(void*,int,char**,char**);
int main()
{
    sqlite3* db;
    int nResult = sqlite3_open("/usr/local/freeswitch/db/fifo.db",&db);
    if (nResult != SQLITE_OK)
    {
        cout<<"打开数据库失败:"<<sqlite3_errmsg(db)<<endl;
        return 0;
    }
    else
    {
        cout<<"数据库打开成功"<<endl;
    }

    char* errmsg;
    string strSql;
    strSql = "select uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, next_avail, expires, static, outbound_call_count, outbound_fail_count, hostname from fifo_outbound";
    nResult = sqlite3_exec(db,strSql.c_str(),callback,NULL,&errmsg);
      if (nResult != SQLITE_OK)
    {
        sqlite3_close(db);
        cout<<errmsg<<endl;
        sqlite3_free(errmsg);
        return 0;
    }

    sqlite3_close(db);
    return 0;
}

int callback(void* ,int nCount,char** pValue,char** pName)
{
    cout<<"call once!!!!!1"<<endl;
    return 1;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值