本文整理汇总了C++中CppSQLite3Table类的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3Table类的具体用法?C++ CppSQLite3Table怎么用?C++ CppSQLite3Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CppSQLite3Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToRBrain
uint32 CBrainMemory::GetAllPartOfSpeech(int64 ParentID){
CppSQLite3Buffer SQL;
char a[30],b[30],c[30];
uint32 PartOfSpeech = 0;
// if(!RBrainHasTable(ID))return 0;
ToRBrain(ParentID);
int64toa(ParentID,a);
int64toa(PARTOFSPEECH_START,b);
int64toa(PARTOFSPEECH_END,c);
SQL.format("select %s from \"%s\" where %s > \"%s\" AND %s< \"%s\";",
RB_SPACE_TYPE,
a,
RB_SPACE_TYPE,
b,
RB_SPACE_TYPE,
c
);
CppSQLite3Table t = BrainDB.getTable(SQL);
for (int row = 0; row < t.numRows(); row++)
{
t.setRow(row);
int64 type = t.getInt64Field(0);
PartOfSpeech |= (uint32)((type-PARTOFSPEECH_START));
}
return PartOfSpeech;
}
示例2: JoinTableDelete
int CDbMeter::JoinTableDelete(const char* dbfilename)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);");
bufSQL.format("SELECT * FROM jointable;");
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
XDEBUG("Failure: Don't have JoinTable\r\n");
}
else
{
db.execDML("DROP TABLE joinTable;");
}
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例3:
BOOL Maxthon3PlugIn::IsWorked()
{
BOOL bRet = FALSE;
if (m_pMemFavoriteDB)
{
CppSQLite3DB objSqliteDatabase;
objSqliteDatabase.openmem(m_pMemFavoriteDB, "");
bRet = objSqliteDatabase.tableExists("MyFavNodes");
if (bRet)
{
CppSQLite3Table objSqliteTable = objSqliteDatabase.getTable("select * from MyFavNodes");
if (14 != objSqliteTable.numFields())
{
bRet = FALSE;
}
}
}
return bRet;
}
示例4: ToRBrain
int32 CLogicThread::GetActionRoom(int64 ParentID,ClauseLogicSense* cls){
CppSQLite3Buffer SQL;
char a[30],b[30];
uint32 PartOfSpeech = 0;
// if(!RBrainHasTable(ID))return 0;
map<int64,MeaningPos>& RoomList = cls->ClauseMeaning;
ToRBrain(ParentID);
int64toa(ParentID,a);
int64toa(MEMORY_INSTINCT,b);
SQL.format("select %s,%s from \"%s\" where %s = \"%s\" ;",
RB_SPACE_ID,
RB_SPACE_VALUE,
a,
RB_SPACE_TYPE,
b
);
CppSQLite3Table t = BrainDB.getTable(SQL);
for (int row = 0; row < t.numRows(); row++)
{
t.setRow(row);
int64 ID = t.getInt64Field(0);
int64 Value = t.getInt64Field(1);
MeaningPos Pos;
Pos.RoomID = ID;
Pos.ParamTokenPos = cls->NextTokenPos;
RoomList[Value] = Pos;
}
return RoomList.size();
}
示例5: AnsiString
void __fastcall TFrmAlarmDetailList::grdErrorDetailSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
TStringGrid* pGrid = ( TStringGrid* )Sender;
MemoSolution->Clear();
MemoCause->Clear();
if(CanSelect = true)
{
if(pGrid->Cells[ 1 ][ ARow ] != "" &&
pGrid->Cells[ 1 ][ ARow ] != "0" )
{
AnsiString szQuery = "SELECT * FROM " + g_szDBList[_nTableIndex];
INT nErrCode = pGrid->Cells[ 1 ][ ARow ].ToInt();
CppSQLite3DB dbMain;
dbMain.open( AnsiString( g_MainDBPath ).c_str() );
CppSQLite3Table tblAlarm = dbMain.getTable( szQuery.c_str() );
tblAlarm.setRow( nErrCode-1 );
const char* szCause = tblAlarm.getStringField( "cause", "" );
const char* szSolution = tblAlarm.getStringField( "solution", "" );
MemoCause->Lines->Add( szCause );
MemoSolution->Lines->Add( szSolution );
dbMain.close();
pGrid->Refresh();
}
}
}
示例6: JoinTableAdd
int CDbMeter::JoinTableAdd(const char* dbfilename, char* szID)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);");
bufSQL.format("SELECT * FROM jointable WHERE EUI64ID=%Q", szID);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
bufSQL.clear();
bufSQL.format("INSERT INTO jointable(EUI64ID, jointry) VALUES(%Q, %d);", szID, 0);
db.execDML(bufSQL);
}
else
XDEBUG("Jointable ID Duplicate!!\r\n");
db.close();
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例7: FormatDateTime
void __fastcall TFrmAlarmDetailList::ChartAlarmClickSeries(TCustomChart *Sender, TChartSeries *Series,
int ValueIndex, TMouseButton Button, TShiftState Shift, int X,
int Y)
{
String strStartDateTime = FormatDateTime("yyyy-mm-dd 오전 00:00:00", DateTimeAlarmStart->Date);
String strEndDateTime = FormatDateTime("yyyy-mm-dd 오전 00:00:00", DateTimeAlarmEnd->Date + 1);
try
{
AnsiString szQuery = " select *, count(Alarm_idx) AS Frequency from AlarmLog "
" where Set_date BETWEEN '" + strStartDateTime + "' AND '" + strEndDateTime + "'"
" AND Alarm_idx < 1000 group by Alarm_idx order by Frequency DESC;";
CppSQLite3Table OrderedTable = dbMain.getTable(szQuery.c_str());
OrderedTable.setRow(ValueIndex);
AnsiString strCode = (String)OrderedTable.fieldValue("Alarm_idx");
AnsiString szAlarmQuery = " select * from AlarmLog, Alarm, Groups, Recipe where Alarm_idx like " + strCode +
" AND Set_date BETWEEN '" + strStartDateTime + "' AND '" + strEndDateTime + "'"
" AND AlarmLog.Alarm_idx = Alarm.idx"
" AND AlarmLog.Group_idx = Groups.idx"
" AND AlarmLog.group_idx = Recipe.group_idx"
" AND AlarmLog.Recipe_idx = Recipe.idx ORDER BY Set_Date DESC";
CppSQLite3Table SelectedTable = dbMain.getTable(szAlarmQuery.c_str());
for(int i = 1; i < grdAlarmLog->RowCount; i++)
{
grdAlarmLog->Rows[i]->Clear();
}
grdAlarmLog->RowCount = 2;
if (SelectedTable.numRows() > 0)
{
for(int row = 0; row < SelectedTable.numRows(); row++)
{
SelectedTable.setRow(row);
grdAlarmLog->Cells[0][row+1] = IntToStr(row+1);
grdAlarmLog->Cells[1][row+1] = (String)SelectedTable.fieldValue(7); // Start date
grdAlarmLog->Cells[2][row+1] = (String)SelectedTable.fieldValue(8); // End date
grdAlarmLog->Cells[3][row+1] = (String)SelectedTable.fieldValue(9); // Alarm Code
grdAlarmLog->Cells[4][row+1] = (String)SelectedTable.fieldValue(11); // Alarm Name
grdAlarmLog->RowCount = row+2;
}
}
}
catch (CppSQLite3Exception& e)
{
cerr << e.errorCode() << ":" << e.errorMessage() << endl;
}
}
示例8: GroupDelete
int CDbMeter::GroupDelete(const char* dbfilename, int nGroupKey)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
// 그룹테이블에 그룹이름이 있느지 확인
CppSQLite3Buffer bufSQL;
//CppSQLite3Query q;
CppSQLite3Table t;
bufSQL.format("SELECT GroupKey FROM groups WHERE GroupKey=%d;", nGroupKey);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
XDEBUG("ERROR: %d GroupKey doesn't exist in Groups Table!!\r\n", nGroupKey);
return IF4ERR_GROUP_NAME_NOT_EXIST;
}
else
{
bufSQL.clear();
bufSQL.format("DELETE FROM groups WHERE GroupKey=%d;", nGroupKey);
db.execDML(bufSQL);
XDEBUG("%d GroupKey deleted in Groups Table!!\r\n", nGroupKey);
//bufSQL.format("SELECT Groups.GroupName FROM groupmember LEFT OUTER JOIN groups ON groupmember.GroupKey=groups.GroupKey LEFT OUTER JOIN member ON groupmember.EUI64ID=member.EUI64ID WHERE groups.GroupName = %s;", szGroupName);
}
bufSQL.clear();
bufSQL.format("SELECT GroupKey FROM groupmember WHERE GroupKey=%d;", nGroupKey);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
XDEBUG("ERROR: %d GroupKey doesn't exist!! in Groupmember Table!!\r\n", nGroupKey);
return IF4ERR_GROUP_NAME_NOT_EXIST;
}
else
{
bufSQL.clear();
bufSQL.format("DELETE FROM groupmember WHERE GroupKey=%d;", nGroupKey);
db.execQuery(bufSQL);
XDEBUG("%d GroupKey deleted in Groupmember Table!!\r\n", nGroupKey);
}
db.close();
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例9: GroupAddMember
int CDbMeter::GroupAddMember(const char* dbfilename, int nGroupKey, char* szMemberId)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Query q;
CppSQLite3Table t;
int nFindgroupkey = -1;
bufSQL.format("SELECT EUI64ID FROM member WHERE EUI64ID=%Q;", szMemberId);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
bufSQL.clear();
bufSQL.format("INSERT INTO member VALUES(%Q, 'Meter', 'none', '1.0.0', '1.0.0', 'Nomal', 'None');", szMemberId);
db.execDML(bufSQL);
}
bufSQL.clear();
bufSQL.format("SELECT * FROM groups WHERE GroupKey=%d;", nGroupKey);
t = db.getTable(bufSQL);
if( t.numRows() == 1)
nFindgroupkey = atoi(t.fieldValue(0));
else
nFindgroupkey = -1;
if( nFindgroupkey >= -1)
{
bufSQL.clear();
bufSQL.format("INSERT INTO groupmember(EUI64ID, GroupKey) VALUES(%Q, %d);", szMemberId, nGroupKey);
db.execDML(bufSQL);
}
db.close();
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return -1;
}
return SQLITE_OK;
}
示例10: strcpy
EXPORT_C gint32 CContactDb::InitEntityDb(gchar* dbName) /* fill fields name */
{
strcpy(m_dbName, dbName);
OpenDatabase();
CppSQLite3Table contactTable = m_dbBeluga.getTable("select * from contact limit 1;");
m_pFieldsName = g_ptr_array_sized_new(contactTable.numFields());
if (!m_pFieldsName)
{
CloseDatabase();
return ERROR(ESide_Client, EModule_Db, ECode_No_Memory);
}
for (int i=0; i<contactTable.numFields(); i++)
g_ptr_array_add(m_pFieldsName, g_string_new((gchar*)contactTable.fieldName(i)));
CloseDatabase();
return 0;
}
示例11: JoinTableShow
int CDbMeter::JoinTableShow(const char* dbfilename)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);");
bufSQL.format("SELECT * FROM jointable;");
t = db.getTable(bufSQL);
for ( int row = 0; row < t.numRows(); row++)
{
t.setRow(row);
for (int fld=0; fld<t.numFields(); fld++)
{
if( !t.fieldIsNull(fld))
XDEBUG("%s | ", t.fieldValue(fld));
}
XDEBUG("\r\n");
}
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例12: AnsiString
void TfrmUseSkipViewer::LoadUseSkipNameFromDB()
{
CppSQLite3DB db;
String szSelectQuery = "SELECT * FROM UseSkip";
try
{
if( FileExists( g_MainDBPath ) == true )
{
db.open( AnsiString( g_MainDBPath ).c_str() );
CppSQLite3Table table = db.getTable( AnsiString( szSelectQuery ).c_str() );
if( table.numRows() != 0 )
{
for( int row = 0; row < table.numRows(); row++ )
{
table.setRow( row );
String szName = table.getStringField( "name", "NULL" );
if( szName == "NULL" || szName == "" )
{
szName = "UseSkip" + IntToStr( row );
}
ComboBoxUseSkip->AddItem( szName, NULL );
}
}
db.close();
}
}
catch(Exception &e)
{
db.close();
ShowMessage("Use Skip DB select error! : " + e.Message);
}
}
示例13: GroupDeleteMember
int CDbMeter::GroupDeleteMember(const char* dbfilename, int nGroupKey, char* szMemberId)
{
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
//CppSQLite3Query q;
CppSQLite3Table t;
bufSQL.format("SELECT * FROM groupmember WHERE GroupKey=%d AND EUI64ID=%Q;", nGroupKey, szMemberId);
//q = db.execQuery(bufSQL);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
XDEBUG("ERROR: %s EUI64ID doesn't exist in %d Groupkey Table!!\r\n", szMemberId, nGroupKey);
return IF4ERR_GROUP_NAME_NOT_EXIST;
}
else
{
bufSQL.clear();
bufSQL.format("DELETE FROM groupmember WHERE GroupKey=%d AND EUI64ID=%Q;", nGroupKey, szMemberId);
db.execQuery(bufSQL);
XDEBUG("%s Groupmember of %d GroupKey deleted in Groupmember Table!!\r\n", szMemberId, nGroupKey);
}
db.close();
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return e.errorCode();
}
return SQLITE_OK;
}
示例14: GroupAdd
//////////////////////////////////////////////////////////////////////////
// [3/23/2011 DHKim]
// 성공적으로 그룹테이블에 그룹이 추가되면 GroupKey를 리턴한다. 실패시 -1을 리턴
//////////////////////////////////////////////////////////////////////////
int CDbMeter::GroupAdd(const char* dbfilename, char* szGroupName)
{
int nGroupKey = -1;
try
{
CppSQLite3DB db;
db.open(dbfilename);
CppSQLite3Buffer bufSQL;
CppSQLite3Table t;
bufSQL.format("INSERT INTO groups(GroupName) VALUES(%Q);", szGroupName);
db.execDML(bufSQL);
XDEBUG("Success: INSERT Command!!\r\n");
bufSQL.clear();
bufSQL.format("SELECT GroupKey FROM groups WHERE GroupName=%Q;", szGroupName);
//CppSQLite3Query q = db.execQuery(bufSQL);
t = db.getTable(bufSQL);
if( t.numRows() == 0 )
{
XDEBUG("Failure: SELECT Command!!\r\n");
return nGroupKey;
}
else
{
// 동일 이름시 마지막에 추가된 그룹 키를 리턴한다.
int nFinalRow = t.numRows() - 1;
t.setRow(nFinalRow);
if( !t.fieldIsNull(nFinalRow) )
nGroupKey = atoi(t.fieldValue(nFinalRow));
else
{
XDEBUG("Error: GroupKey is NULL!!\r\n");
return nGroupKey;
}
XDEBUG("Success: SELECT Command!!\r\n");
}
//nGroupKey = q.getIntField("GroupKey", -1);
db.close();
}
catch( CppSQLite3Exception& e )
{
XDEBUG("%s\r\n",e.errorMessage());
return -1;
}
return nGroupKey;
}
示例15: _T
void CDlgAnswerList::ShowPage(int nPageIndex)
{
CString str = _T("");
int i = 0;
int nStartIndex = 0;
int nOffset = 0;
CppSQLite3Table t;
CppSQLite3Query q;
CppSQLite3DB db;
db.open(PATH_SQLITE_DB_808); //打开数据库
char szSqlBuffer[1024];
memset(szSqlBuffer, 0, sizeof(szSqlBuffer));
//查询记录总数量
// sprintf(szSqlBuffer, "SELECT COUNT(*) FROM answer \
// WHERE UID IN (SELECT UID FROM question ORDER BY question_datatime DESC LIMIT %d, 1) \
// ORDER BY answer_ID;",
// m_nQuestionIndex);
// m_nRecordCount = db.execScalar( szSqlBuffer );
sprintf(szSqlBuffer, "SELECT * FROM answer where UID = '%d';", m_nQuestionIndex);
t = db.getTable(szSqlBuffer);
m_nRecordCount = t.numRows();
//计算总页数
if(m_nRecordCount > 0)
m_nPageCount = (m_nRecordCount-1)/elist_count+1;
else
m_nPageCount = 1;
memset(szSqlBuffer, 0, sizeof(szSqlBuffer));
sprintf(szSqlBuffer, "SELECT * FROM question where UID = '%d';", m_nQuestionIndex);
q = db.execQuery(szSqlBuffer);
int nFlag = q.getIntField("flag");
const char* ccText = q.fieldValue("question_content");
str = ccText;
//在数据库中查询第nPageIndex页的elist_count条数据
// sprintf(szSqlBuffer, "SELECT * FROM answer \
// WHERE UID IN (SELECT UID FROM question ORDER BY question_datatime DESC LIMIT %d, 1) \
// ORDER BY answer_ID LIMIT %d, %d;",
// m_nQuestionIndex, nPageIndex*elist_count, elist_count);
// q = db.execQuery(szSqlBuffer);
memset(szSqlBuffer, 0, sizeof(szSqlBuffer));
sprintf(szSqlBuffer, "SELECT * FROM answer where UID = '%d' LIMIT %d, %d;",
m_nQuestionIndex, (nPageIndex)*elist_count, elist_count);
q = db.execQuery(szSqlBuffer);
for( i = 0; i < elist_count; i++ )
{
if ( !q.eof() ) //数据行
{
m_nAnswerID[i] = q.getIntField("answer_ID");
m_list[i].chChar = q.fieldValue("answer_content");
m_list[i].nState = BTN_STATE_NORMAL;
q.nextRow();
}
else //空白行
{
m_ItemState[i] = 0;
m_list[i].chChar = _T("");
m_list[i].nState = BTN_STATE_DISABLE;
}
}
//释放statement
q.finalize();
db.close(); //关闭数据库
if(nFlag)
TTSSpeaking( str );
return;
}