diff options
Diffstat (limited to 'src/include/xbsql.h')
-rwxr-xr-x | src/include/xbsql.h | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/src/include/xbsql.h b/src/include/xbsql.h index 653096c..07ffb70 100755 --- a/src/include/xbsql.h +++ b/src/include/xbsql.h @@ -39,7 +39,83 @@ struct XBDLLEXPORT xbSqlFld{ xbSqlFld * Next; // Next field in list }; +class xbStmt; + + +struct XBDLLEXPORT xbTblJoin { // structure for defining joined tables in the query + + xbString sTableName; + xbString sAlias; + xbString sJoinExp; // table join expression + xbDbf *pDbf; // pointer the the dbf structure for this table + xbTag *pTag; // pointer to relevant tag for this table, null for record order + xbExp *pLinkExp; // pointer to parsed linkage expression + char cJoinType; // M - Master + // L - Left or Full Left + // R - Right or Full Right + // I - Inner + // O - Outer or Full Outer Outer + + xbTblJoin *pMaster; // pointer to master table, null if this is the primary master + xbLinkList<xbTblJoin *> llSubList; // linked list of subordinate tables +// xbStmt *pSubQuery; // pointer to sub query + xbTblJoin *next; // next tbl +}; + + +class XBDLLEXPORT xbStmt : public xbSsv{ + + public: + xbStmt( xbXBase *x ); + ~xbStmt(); + + #ifdef XB_DEBUG_SUPPORT + xbInt16 DumpStmtInternals(); + xbInt16 Test(); + #endif + + xbInt16 ExecuteQuery( const xbString &sCmdLine ); + +// xbInt16 FetchFirst(); +// xbInt16 FetchNext(); +// xbInt16 FetchPrev(); +// xbInt16 FetchLast(); +// xbString &GetField( const xbString sFldName ); + protected: + + private: + + xbInt16 AddQryTbl( const xbString &sTable, const xbString &sAlias, const xbString &sExpression, const char cJoinType ); + xbInt16 CvtSqlExp2DbaseExp( const xbString &sExpIn, xbString &sExpOut ); + xbInt16 GetNextFromSeg( const xbString &sLineIn, xbString &sFromSegOut ); + xbUInt32 GetNextToken( const xbString &sCmdLineIn, xbString &sTokenOut, xbUInt32 ulStartPos ); + xbInt16 GetParenCnt( const xbString &sToken ); + xbInt16 ParseFromStmt( const xbString &sFromLine ); + xbInt16 ParseStmt( const xbString &sCmdLine ); + xbInt16 ProcessFromSeg( const xbString &sFromStmtSeg ); + xbInt16 UpdateJoinList( char cType, const xbString &sTableName, const xbString &sAlias, const xbString &sExp, xbDbf *d, xbExp *e ); //, xbTag *t); + + xbXBase *xbase; // pointer to xbase structure + + + xbTblJoin * pTblList; + xbSqlFld *fl; // field list in sql select statement + xbString sStmt; // complete query statment + xbString sFields; // list of fields + xbString sFrom; // from statment + xbString sWhere; // where clause + xbString sOrderBy; // sort order + xbString sGroupBy; // group by + xbString sHaving; // having + xbUInt32 ulFromPos; + xbUInt32 ulWherePos; + xbUInt32 ulOrderByPos; + xbUInt32 ulGroupByPos; + xbUInt32 ulHavingPos; + + +}; class XBDLLEXPORT xbSql : public xbSsv { @@ -68,7 +144,7 @@ class XBDLLEXPORT xbSql : public xbSsv { // xbInt16 SqlCreateView( const xbString &sCmdLine ); // xbInt16 SqlDropView( const xbString &sCmdLine ); // xbInt16 SqlUpdate( const xbString &sCmdLine ); - xbInt16 SqlSelect( const xbString &sCmdLine ); +// xbInt16 SqlSelect( const xbString &sCmdLine ); void SqlHelp() const; xbInt16 SqlInsert( const xbString &sCmLine ); |