⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbinterface.c

📁 一个在linux下连接Sybase数据库
💻 C
📖 第 1 页 / 共 5 页
字号:
# line 133 "dbInterface.cpp"
               _sqlinitctx(&_sql, CS_VERSION_150, CS_TRUE, &sqlca, (long 
# line 133 "dbInterface.cpp"
                   *)NULL, (CS_CHAR *)NULL);
# line 133 "dbInterface.cpp"
               if (_sql != (_SQL_CT_HANDLES *) NULL)
# line 133 "dbInterface.cpp"
               {
# line 133 "dbInterface.cpp"
                   _sql->stmtData.persistent = CS_FALSE;
# line 133 "dbInterface.cpp"
                   _sql->moreData.curData.norebind = CS_FALSE;
# line 133 "dbInterface.cpp"
                   _sql->stmttype = SQL_OPEN_STMT;
# line 133 "dbInterface.cpp"
                   _sql->connName.lnlen = CS_UNUSED;
# line 133 "dbInterface.cpp"
                   _sql->curName.fnlen = 12;
# line 133 "dbInterface.cpp"
                   strcpy(_sql->curName.first_name, "AlarmsTable1");
# line 133 "dbInterface.cpp"
                   if ((_sql->retcode = _sqlprolog(_sql)) == CS_SUCCEED)
# line 133 "dbInterface.cpp"
                   {
# line 133 "dbInterface.cpp"
                       if (_sql->doDecl == CS_TRUE)
# line 133 "dbInterface.cpp"
                       {
# line 133 "dbInterface.cpp"
                           _sql->retcode = ct_cursor(_sql->conn.command, 
# line 133 "dbInterface.cpp"
                               CS_CURSOR_DECLARE, "AlarmsTable1", 12, "select ("
"convert(char(10),Time,102))+' '+(convert(char(9),Time,108)), AlarmCode,Info fr"
"om SapLogDB.dbo.TBL_Alarms  a where not exists(select 1 from SapLogDB.dbo.TBL_"
"Alarms where AlarmCode%16 =a.AlarmCode%16 and Time>a.Time)", 222, CS_UNUSED);
# line 133 "dbInterface.cpp"
                       }
# line 133 "dbInterface.cpp"
                       
# line 133 "dbInterface.cpp"
                       if (_sql->retcode == CS_SUCCEED)
# line 133 "dbInterface.cpp"
                       {
# line 133 "dbInterface.cpp"
                           if (_sql->stmtData.persistent == CS_TRUE)
# line 133 "dbInterface.cpp"
                           {
# line 133 "dbInterface.cpp"
                               _sql->retcode = ct_cursor(_sql->conn.command, 
# line 133 "dbInterface.cpp"
                                   CS_CURSOR_OPEN, NULL, CS_UNUSED, NULL, 
# line 133 "dbInterface.cpp"
                                   CS_UNUSED, CS_RESTORE_OPEN);
# line 133 "dbInterface.cpp"
                               }
# line 133 "dbInterface.cpp"
                                else {
# line 133 "dbInterface.cpp"
                               _sql->retcode = ct_cursor(_sql->conn.command, 
# line 133 "dbInterface.cpp"
                                   CS_CURSOR_OPEN, NULL, CS_UNUSED, NULL, 
# line 133 "dbInterface.cpp"
                                   CS_UNUSED, CS_UNUSED);
# line 133 "dbInterface.cpp"
                           }
# line 133 "dbInterface.cpp"
                           
# line 133 "dbInterface.cpp"
                       }
# line 133 "dbInterface.cpp"
                       
# line 133 "dbInterface.cpp"
                       if (_sql->retcode == CS_SUCCEED)
# line 133 "dbInterface.cpp"
                       {
# line 133 "dbInterface.cpp"
                           _sql->retcode = ct_send(_sql->conn.command);
# line 133 "dbInterface.cpp"
                           _sql->hastate = (_sql->retcode == 
# line 133 "dbInterface.cpp"
                               CS_RET_HAFAILOVER);
# line 133 "dbInterface.cpp"
                       }
# line 133 "dbInterface.cpp"
                       
# line 133 "dbInterface.cpp"
                       _sql->resloop = CS_TRUE;
# line 133 "dbInterface.cpp"
                       while ((!_sql->hastate) && (_sql->resloop == CS_TRUE) 
# line 133 "dbInterface.cpp"
                           && ((_sql->retcode = ct_results(_sql->conn.command, 
# line 133 "dbInterface.cpp"
                           &_sql->restype)) == CS_SUCCEED))
# line 133 "dbInterface.cpp"
                       {
# line 133 "dbInterface.cpp"
                           switch ( _sql->restype )
# line 133 "dbInterface.cpp"
                           {
# line 133 "dbInterface.cpp"
                           case CS_COMPUTE_RESULT:
# line 133 "dbInterface.cpp"
                               _sqlsetintrerr(_sql, (CS_INT) 
# line 133 "dbInterface.cpp"
                                   _SQL_INTRERR_25003);
# line 133 "dbInterface.cpp"
                               _sql->retcode = ct_cancel(NULL, 
# line 133 "dbInterface.cpp"
                                   _sql->conn.command, CS_CANCEL_CURRENT);
# line 133 "dbInterface.cpp"
                           break;
# line 133 "dbInterface.cpp"
                           case CS_CURSOR_RESULT:
# line 133 "dbInterface.cpp"
                               _sql->resloop = CS_FALSE;
# line 133 "dbInterface.cpp"
                           break;
# line 133 "dbInterface.cpp"
                           case CS_PARAM_RESULT:
# line 133 "dbInterface.cpp"
                               _sqlsetintrerr(_sql, (CS_INT) 
# line 133 "dbInterface.cpp"
                                   _SQL_INTRERR_25005);
# line 133 "dbInterface.cpp"
                               _sql->retcode = ct_cancel(NULL, 
# line 133 "dbInterface.cpp"
                                   _sql->conn.command, CS_CANCEL_CURRENT);
# line 133 "dbInterface.cpp"
                           break;
# line 133 "dbInterface.cpp"
                           case CS_ROW_RESULT:
# line 133 "dbInterface.cpp"
                               _sqlsetintrerr(_sql, (CS_INT) 
# line 133 "dbInterface.cpp"
                                   _SQL_INTRERR_25006);
# line 133 "dbInterface.cpp"
                               _sql->retcode = ct_cancel(NULL, 
# line 133 "dbInterface.cpp"
                                   _sql->conn.command, CS_CANCEL_CURRENT);
# line 133 "dbInterface.cpp"
                           break;
# line 133 "dbInterface.cpp"
                           case CS_STATUS_RESULT:
# line 133 "dbInterface.cpp"
                               _sqlsetintrerr(_sql, (CS_INT) 
# line 133 "dbInterface.cpp"
                                   _SQL_INTRERR_25009);
# line 133 "dbInterface.cpp"
                               _sql->retcode = ct_cancel(NULL, 
# line 133 "dbInterface.cpp"
                                   _sql->conn.command, CS_CANCEL_CURRENT);
# line 133 "dbInterface.cpp"
                           break;
# line 133 "dbInterface.cpp"
                           case CS_DESCRIBE_RESULT:
# line 133 "dbInterface.cpp"
                               _sqlsetintrerr(_sql, (CS_INT) 
# line 133 "dbInterface.cpp"
                                   _SQL_INTRERR_25010);
# line 133 "dbInterface.cpp"
                           break;
# line 133 "dbInterface.cpp"
                           }
# line 133 "dbInterface.cpp"
                           
# line 133 "dbInterface.cpp"
                       }
# line 133 "dbInterface.cpp"
                       
# line 133 "dbInterface.cpp"
                       _sql->retcode = _sqlepilog(_sql);
# line 133 "dbInterface.cpp"
                   }
# line 133 "dbInterface.cpp"
                   
# line 133 "dbInterface.cpp"
               }
# line 133 "dbInterface.cpp"
               
# line 133 "dbInterface.cpp"
           }
# line 133 "dbInterface.cpp"
           

           /*
           ** Generated code ends here.
           */
# line 133 "dbInterface.cpp"

		if(sqlca.sqlcode < 0) return sqlca.sqlcode;
    }
	memset(&TAlarms, 0, sizeof(TAlarms));

    
           /*
           ** SQL STATEMENT: 11
           ** exec sql fetch AlarmsTable1 into :TAlarms.Time, :TAlarms.AlarmCode,
           ** :TAlarms.Info;
           */
# line 138 "dbInterface.cpp"
# line 138 "dbInterface.cpp"
           {
# line 138 "dbInterface.cpp"
                _SQL_CT_HANDLES * _sql;
# line 138 "dbInterface.cpp"
               _sqlinitctx(&_sql, CS_VERSION_150, CS_TRUE, &sqlca, (long 
# line 138 "dbInterface.cpp"
                   *)NULL, (CS_CHAR *)NULL);
# line 138 "dbInterface.cpp"
               if (_sql != (_SQL_CT_HANDLES *) NULL)
# line 138 "dbInterface.cpp"
               {
# line 138 "dbInterface.cpp"
                   _sql->stmtData.persistent = CS_FALSE;
# line 138 "dbInterface.cpp"
                   _sql->stmttype = SQL_FETCH_STMT;
# line 138 "dbInterface.cpp"
                   _sql->connName.lnlen = CS_UNUSED;
# line 138 "dbInterface.cpp"
                   _sql->curName.fnlen = 12;
# line 138 "dbInterface.cpp"
                   strcpy(_sql->curName.first_name, "AlarmsTable1");
# line 138 "dbInterface.cpp"
                   if ((_sql->retcode = _sqlprolog(_sql)) == CS_SUCCEED)
# line 138 "dbInterface.cpp"
                   {
# line 138 "dbInterface.cpp"
                       _sql->doDecl = CS_FALSE;
# line 138 "dbInterface.cpp"
                       if ((_sql->stmtData.bind == CS_TRUE) ||
# line 138 "dbInterface.cpp"
                       (_sql->moreData.curData.norebind == CS_FALSE))
# line 138 "dbInterface.cpp"
                       {
# line 138 "dbInterface.cpp"
                           _sql->dfmtNULLCHAR.count = 0;
# line 138 "dbInterface.cpp"
                           _sql->dfmtNULLCHAR.maxlength = 32;
# line 138 "dbInterface.cpp"
                           _sql->dfmtNULLCHAR.format = CS_FMT_NULLTERM;
# line 138 "dbInterface.cpp"
                               _sql->retcode = ct_bind(_sql->conn.command, 1, 
# line 138 "dbInterface.cpp"
                                   &_sql->dfmtNULLCHAR, TAlarms.Time, NULL, 
# line 138 "dbInterface.cpp"
                                   NULL);
# line 138 "dbInterface.cpp"
                           _sql->dfmtCS_INT_TYPE.count = 0;
# line 138 "dbInterface.cpp"
                               _sql->retcode = ct_bind(_sql->conn.command, 2, 
# line 138 "dbInterface.cpp"
                                   &_sql->dfmtCS_INT_TYPE, &TAlarms.AlarmCode, 
# line 138 "dbInterface.cpp"
                                   NULL, NULL);
# line 138 "dbInterface.cpp"
                           _sql->dfmtNULLCHAR.count = 0;
# line 138 "dbInterface.cpp"
                           _sql->dfmtNULLCHAR.maxlength = 256;
# line 138 "dbInterface.cpp"
                           _sql->dfmtNULLCHAR.format = CS_FMT_NULLTERM;
# line 138 "dbInterface.cpp"
                               _sql->retcode = ct_bind(_sql->conn.command, 3, 
# line 138 "dbInterface.cpp"
                                   &_sql->dfmtNULLCHAR, TAlarms.Info, NULL, 
# line 138 "dbInterface.cpp"
                                   NULL);
# line 138 "dbInterface.cpp"
                           if (_sql->stmtData.bind == CS_TRUE)
# line 138 "dbInterface.cpp"
                           {
# line 138 "dbInterface.cpp"
                               _sql->stmtData.bind = CS_FALSE;
# line 138 "dbInterface.cpp"
                               _sql->doDecl = CS_TRUE;
# line 138 "dbInterface.cpp"
                           }
# line 138 "dbInterface.cpp"
                           
# line 138 "dbInterface.cpp"
                       }
# line 138 "dbInterface.cpp"
                       
# line 138 "dbInterface.cpp"
                       _sql->retcode = ct_fetch(_sql->conn.command, CS_UNUSED, 
# line 138 "dbInterface.cpp"
                           CS_UNUSED, CS_UNUSED, &_sql->rowsread);
# line 138 "dbInterface.cpp"
                       _sql->hastate = (_sql->retcode == CS_RET_HAFAILOVER);
# line 138 "dbInterface.cpp"
                       if ((_sql->retcode == CS_END_DATA)||(_sql->retcode == 
# line 138 "dbInterface.cpp"
                       CS_FAIL)||
# line 138 "dbInterface.cpp"
                       (_sql->retcode == CS_SCROLL_CURSOR_ENDS))
# line 138 "dbInterface.cpp"
                       {
# line 138 "dbInterface.cpp"
                           _sql->retcode = _sqlResults(_sql);
# line 138 "dbInterface.cpp"
                       }
# line 138 "dbInterface.cpp"
                       
# line 138 "dbInterface.cpp"
                       _sql->retcode = _sqlepilog(_sql);
# line 138 "dbInterface.cpp"
                   }
# line 138 "dbInterface.cpp"
                   
# line 138 "dbInterface.cpp"
               }
# line 138 "dbInterface.cpp"
               
# line 138 "dbInterface.cpp"
           }
# line 138 "dbInterface.cpp"
           

           /*
           ** Generated code ends here.
           */
# line 138 "dbInterface.cpp"

    if(sqlca.sqlcode < 0) return sqlca.sqlcode;
    if(sqlca.sqlcode == 0)
    {
    	memcpy(pNums->DateTime,TAlarms.Time,sizeof((*pNums).DateTime));
		memcpy(pNums->Info,TAlarms.Info,sizeof((*pNums).Info));
		memcpy(&pNums->AlarmCode,&TAlarms.AlarmCode,sizeof(sizeof(pNums->AlarmCode)));
		return 1;
    }
    else if(sqlca.sqlcode == 100)
    {
		/*exec sql close AlarmsTable1;*/
		return 0;
    }

	return sqlca.sqlcode;
}

/*
** SQL STATEMENT: 12
** exec sql declare SMSendStrategy cursor for select * from SapDB.dbo.TBL_SMSendS
** trategy;

*/
# line 155 "dbInterface.cpp"

int ReadSMSendStrategy(SendStrategy* pNums, int isFromBegin, int id)
{
	
           /*
           ** SQL STATEMENT: 12
           ** exec sql begin declare section;

           */
# line 158 "dbInterface.cpp"

 	struct _SendStrategy
 	{
 		CS_INT 			InfoType;
		CS_TINYINT	 	AlarmMode;
		CS_INT			DelayTime;
		CS_INT 			DelayCount;
		CS_CHAR 		MSISDN_AlarmList[128];
 	} Strategy;
	
           /*
           ** SQL STATEMENT: 13
           ** exec sql end declare section;

           */
# line 167 "dbInterface.cpp"

           /*
           ** Generated code ends here.
           */
# line 167 "dbInterface.cpp"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -