asiclass.h 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. // Name: asiclass.h ast_asi_inc_appl_asiclass_h
  12. //
  13. // Description: Header file for AutoCAD SQL Interface.
  14. // ASI C++ User Interface.
  15. #ifndef ASI_ASICLASS_HH
  16. #define ASI_ASICLASS_HH asiclasshh
  17. ///////////////////////////////////////////////////////////////////////////
  18. // INCLUDES
  19. ///////////////////////////////////////////////////////////////////////////
  20. #include <asisdata.h>
  21. #include <avoidtry.h> //for DecreaseGlobalAccount only
  22. ///////////////////////////////////////////////////////////////////////////
  23. // DEFINES
  24. ///////////////////////////////////////////////////////////////////////////
  25. #define ASI_TRY { CAsiExceptionHandler AsiExceptionHandler; try {
  26. #define ASI_CATCH(x) } catch(CAsiException* x) { x=x;
  27. #define ASI_END_CATCH }}
  28. #define ASI_THROW(x) AsiExceptionThrow(x);
  29. #define ASI_THROW_LAST AsiExceptionThrow(0);
  30. ///////////////////////////////////////////////////////////////////////////
  31. // FORWARD DEFINITIONS
  32. ///////////////////////////////////////////////////////////////////////////
  33. #pragma pack (push, 8)
  34. // ASI Class Hierarchy
  35. //
  36. class DLLScope CAsiObject; // Superclass for all classes
  37. class CAsiHostBuffer; // Host program buffer
  38. class CAsiParameter; // Parameter desriptor
  39. class CAsiException; // ASI Exception
  40. class CAsiSQLObject; // ASI User Interface base class
  41. class CAsiSession; // SQL Session
  42. class CAsiStm; // Generic SQL statement functionality
  43. class CAsiExecStm; // Executable SQL statement
  44. class CAsiCsr; // Cursor
  45. class CAsiCsrTable; // Superclass for table access
  46. class CAsiCsrRegTable; // Regular table access
  47. class CAsiCsrInfSchema; // Information Schema access
  48. class CAsiEnumerator; // Data Source access.
  49. class CAsiBinding; // Input/Output parameters support
  50. class CAsiDSProperties;
  51. class CAsiTACond;
  52. class CAsiTCCond;
  53. class CAsiExceptionHandler; // Exception handler
  54. ///////////////////////////////////////////////////////////////////////////
  55. // TYPEDEFS
  56. ///////////////////////////////////////////////////////////////////////////
  57. typedef enum {
  58. kOpNodeUndefined = 0, /* Undefined node */
  59. /* Boolean operations */
  60. kOpNot, /* Not */
  61. kOpOr, /* Or */
  62. kOpAnd, /* And */
  63. kOpTest, /* Boolean test */
  64. /* Comparision predicate */
  65. kOpNull, /* is Null */
  66. kOpGtr, /* > */
  67. kOpGeq, /* >= */
  68. kOpEq, /* = */
  69. kOpLeq, /* <= */
  70. kOpLss, /* < */
  71. kOpNeq /* <> */
  72. } EAsiCompType;
  73. /////////////////////////////////////////////////////////////////////////
  74. class CAsiExceptionHandler
  75. // This class is used internaly to support asi exception handling
  76. // feature
  77. {
  78. public:
  79. // Constrution/destruction
  80. //
  81. CAsiExceptionHandler(void);
  82. ~CAsiExceptionHandler(void);
  83. // Internal data for support TRY/CATCH
  84. //
  85. CAsiException* pException;
  86. CAsiExceptionHandler* pPrevHandler;
  87. EAsiBoolean wasThrown;
  88. };
  89. //////////////////////////////////////////////////////////////////////
  90. class CAsiException : public CAsiObject
  91. //
  92. // This class provides functionality of the SQL exception condition
  93. // It is thrown by ASI member function when an exception condition was
  94. // raised. (ASI_TRY, ASI_CATCH, ASI_THROW facility).
  95. //
  96. {
  97. friend class CAsiSQLObject;
  98. public:
  99. // Constrution/destruction
  100. CAsiException (void);
  101. virtual ~CAsiException (void);
  102. // Getting Diagnostics Information
  103. //
  104. int CondQty (void) const; // Number of conditions in diag
  105. AsiError Err (int d = 0) const; // get completion code
  106. CAsiUcStr * ErrMsg (int d = 0) const; // get error message
  107. char * SQLSTATE (int d = 0) const; // get SQLSTATE
  108. int ErrPosition (void) const;
  109. // Get Diagnostics Parameter
  110. //
  111. EAsiBoolean getDiagPar (int, AsiDiag, integer *) const;
  112. EAsiBoolean getDiagPar (int, AsiDiag, CAsiUcStr *) const;
  113. // Setting Diagnostics information
  114. EAsiBoolean setErr (AsiError); // set completion code
  115. EAsiBoolean setErrMsg (const CAsiUcStr &); // set error message
  116. EAsiBoolean setSQLSTATE (const char *); // set SQLSTATE // Unicode: Leave it as "char", it represents a buffer.
  117. // Set Diagnostics Parameter
  118. //
  119. EAsiBoolean setDiagPar (AsiDiag, integer);
  120. EAsiBoolean setDiagPar (AsiDiag, const CAsiUcStr &);
  121. EAsiBoolean pushCond (void); // Push diagnostics information
  122. EAsiBoolean flushCond (void); // Clear diagnostics
  123. ////////////////////////////////////////////////////
  124. // Utility
  125. //
  126. void * getDiagData (void) const;
  127. void setErrPosition (int);
  128. virtual CAsiObject * duplicate (void) const;
  129. private:
  130. void * pExceptionBody;
  131. };
  132. ////////////////////////////////////////////////////////////////////////////////
  133. class CAsiSQLObject : public CAsiObject
  134. //
  135. // This is a base class for classes that support SQL Connection-Session-
  136. // Statement-Cursor functionality. It provides storage for the diagnostics
  137. // information generated by the derived classes.
  138. // Besides diagnostics this class allows to get information about foreground
  139. // DBMS driver, and the current ASI version.
  140. //
  141. // MEMBER FUNCTIONS
  142. // ----------------
  143. //
  144. //
  145. // Getting Statement Information
  146. //
  147. // EAsiStatement StmType (void) const
  148. // EAsiStatement CmdStmType (void) const
  149. // long RowCount (void) const
  150. //
  151. // These function retrieve SQL statement type, SQL Command statement type,
  152. // number of rows affected by the <update:searched>, <delete: searched>, or
  153. // insert statements
  154. //
  155. //
  156. // Syntax error position
  157. //
  158. // int ErrPosition (void) const
  159. //
  160. // Getting Diagnostics Information
  161. //
  162. // int CondQty (void) const
  163. //
  164. // This function returns number of conditions stored in diagnostics area
  165. // associated with the SQL object. Diagnostics area can hold several items
  166. // belonging to the same or different conditions. Eash new condition in the
  167. // diagnostics area introduces a new condition or clarifies a previouss one.
  168. //
  169. //
  170. // EAsiError Err(
  171. // int icond) const // Condition number
  172. //
  173. // This function returns error code associated with the condition specified
  174. // by its number. Condition codes are listed in the asiconst.h header file.
  175. // If a wrong condition number was passed, kAsiERUndefined is returned.
  176. //
  177. //
  178. // CAsiUcStr *ErrMsg (
  179. // int icond) const // Condition number
  180. //
  181. // This function returns pointer to the Unicode string object that contains
  182. // message associated with specified condition. If invalid condition number
  183. // was specified, 0 is returned instead of it.
  184. //
  185. //
  186. // char * SQLSTATE (
  187. // int icond) const // Condition number
  188. //
  189. // This function returns pointer to the character ASCII string containing
  190. // SQLSTATE diagnostics parameter associated with the specified condition.
  191. // (SQLSTATE parameter is a 5 bytes null terminated charater string,
  192. // consisting of class and subclass codes). If an invalid condition number
  193. // was specified, NULL is returned instead of pointer.
  194. //
  195. //
  196. // EAsiBoolean getDiagPar (int icond, // Condition number
  197. // EAsiDiag pCode, // Parameter code
  198. // integer *ivalue // Integer parameter value
  199. // ) const
  200. // EAsiBoolean getDiagPar (int icond, // Condition number
  201. // EAsiDiag pCode, // Parameter code
  202. // CAsiUcStr *ucvalue // Character parameter value
  203. // ) const;
  204. //
  205. // These functions store value of diagnostics parameter specified by its
  206. // code (pCode) for the specified condition into integer or Unicode
  207. // character string buffers. Return kAsiTrue if succeeded, or kAsiFalse
  208. // if an invalid condition number was specified.
  209. //
  210. // Parameters
  211. //
  212. // icond Condition number
  213. // pCode Diagnostics parameter code
  214. // ivalue Destination for an integer value
  215. // ucvalue Destination for an Unicode character string
  216. //
  217. //
  218. // Linked DBMS information
  219. //
  220. // The following functions allow to get information about DBMS driver
  221. // that maintains link between ASI application and DBMS server.
  222. //
  223. // EAsiBoolean DBMS (
  224. // CAsiUcStr & dbms // DBMS Name
  225. // ) const
  226. //
  227. // Stores DBMS name into Ucode string. Reference to the Unicode string
  228. // shall be provided by caller.
  229. //
  230. //
  231. // EAsiBoolean SQLObject (
  232. // CAsiUcStr &objid // SQL object identifier
  233. // ) const
  234. //
  235. // Stores SQL object identifier into Ucode string. Reference to the destination
  236. // Unicode string shall be provided by caller.
  237. //
  238. //
  239. // EAsiBoolean DrvMessage (
  240. // CAsiUcStr &mess // Driver message
  241. // ) const
  242. //
  243. // Stores driver message into Ucode string. Reference to the destination
  244. // Unicode string shall be provided by caller.
  245. //
  246. //
  247. // EAsiBoolean CheckOp (
  248. // ulong operation // Operation codes
  249. // )
  250. //
  251. // Return kAsiTrue if operations specified in the parameter are supported
  252. // by DBMS driver. Operation codes are a bit coded fields, that can be ored.
  253. // kAsiFalse is returned if at least one operation is not supported.
  254. //
  255. //
  256. // ASI version
  257. //
  258. // EAsiBoolean Version (
  259. // CAsiUcStr* // Pointer for store ASI version string
  260. // ) const
  261. //
  262. // const char* Version (void) const
  263. //
  264. // Return pointer to the unocode string containing ASI version.
  265. //
  266. //
  267. {
  268. friend class CAsiCsr;
  269. friend class CAsiExecStm;
  270. friend class CAsiBinding;
  271. public:
  272. // Constrution/destruction
  273. //
  274. protected:
  275. CAsiSQLObject ();
  276. // Setting Diagnostics information
  277. protected:
  278. virtual EAsiBoolean setErr (EAsiError); // set completion code
  279. virtual EAsiBoolean setErrMsg (const CAsiUcStr &); // set error message
  280. virtual EAsiBoolean setSQLSTATE (const char *); // set SQLSTATE // Unicode: Leave it as "char", it represents a buffer.
  281. // Set Diagnostics Parameter
  282. //
  283. virtual EAsiBoolean setDiagPar (EAsiDiag, integer);
  284. virtual EAsiBoolean setDiagPar (EAsiDiag, const CAsiUcStr &);
  285. virtual EAsiBoolean pushCond (void); // Push diagnostics information
  286. virtual EAsiBoolean flushCond (void);
  287. virtual EAsiBoolean pushErr (EAsiError); // Push diagnostics information
  288. virtual EAsiBoolean pushHResult(HRESULT); // Push diagnostics information
  289. public:
  290. virtual ~CAsiSQLObject ();
  291. // Getting Statement Information
  292. //
  293. EAsiStatement StmType (void) const; // statement type
  294. LONG_PTR RowCount (void) const; // get row count
  295. // This is optional method for defining cursor
  296. virtual EAsiBoolean IsRowset (void) const; // Can object create rowset?
  297. // Syntax error position
  298. virtual int ErrPosition (void) const;
  299. // Getting Diagnostics Information
  300. //
  301. virtual int CondQty (void) const; // Number of conditions in diag
  302. virtual EAsiError Err (int d = 0) const; // get completion code
  303. virtual CAsiUcStr * ErrMsg (int d = 0); // get error message
  304. virtual char * SQLSTATE (int d = 0); // get SQLSTATE
  305. // Get Diagnostics Parameter
  306. //
  307. virtual EAsiBoolean getDiagPar (int d, // Integer condition
  308. EAsiDiag,
  309. integer *) const;
  310. virtual EAsiBoolean getDiagPar (int d, // character condition
  311. EAsiDiag,
  312. CAsiUcStr *) const;
  313. // Linked DBMS information
  314. //
  315. EAsiBoolean DBMS (CAsiUcStr *) const; // DBMS type
  316. EAsiBoolean SQLObject (CAsiUcStr *) const; // SQL object identifier
  317. EAsiBoolean DrvMessage (CAsiUcStr *) const; // Driver message
  318. EAsiBoolean CheckOp (ulong); // Check base operation
  319. virtual EAsiBoolean GetStatus (EAsiStatInfo, ULONG_PTR *); // Get check status
  320. // ASI version
  321. //
  322. const char * Version (void) const;
  323. protected:
  324. EAsiBoolean isInit (void) const;
  325. EAsiBoolean InitErrorInfo (HRESULT, IUnknown *, GUID);
  326. void ReleaseErrorInfo ();
  327. void InheritStatusInfo (const CAsiSQLObject &);
  328. protected:
  329. //
  330. IErrorInfo * m_pIErrorInfo; // Error info
  331. HRESULT m_HResult;
  332. private:
  333. // ASI version string
  334. //
  335. static const char * m_pAsiVersion;
  336. CAsiException m_Except;
  337. protected:
  338. EAsiBoolean m_CSP;
  339. protected:
  340. EAsiStatement m_eStmType;
  341. LONG_PTR m_lRowCount;
  342. CAsiDSProperties * m_pDSProperties;
  343. };
  344. ////////////////////////////////////////////////////////////////////////////
  345. class CAsiAppl: public CAsiSQLObject
  346. // This class is introduces functionality of ASI application
  347. // initialization/termination and disconnectinf from all
  348. // SQL environments. It is derived from the CAsiSQLObject class
  349. // to provide caller with diagnostics info.
  350. //
  351. {
  352. friend class CAsiSession;
  353. friend class CAsiEnumerator;
  354. friend class CAsiCsr;
  355. public:
  356. // Construction/destruction
  357. //
  358. CAsiAppl ();
  359. virtual ~CAsiAppl ();
  360. // Application initialization/termination, Disconnect all
  361. //
  362. EAsiBoolean Init (void); // Initialize application
  363. EAsiBoolean Term (void); // Terminate application
  364. EAsiBoolean Abort (void); // Abort application (rollback all active transactions
  365. EAsiBoolean DisconnectAll (void); // Disconnect from all environmants
  366. protected:
  367. EAsiBoolean addConnection (CAsiSession *);
  368. EAsiBoolean removeConnection(CAsiSession *);
  369. private:
  370. EAsiBoolean rollbackAll (void);
  371. private:
  372. IClassFactory * m_pIClassFactory; // Csp Class Factory
  373. IDataInitialize * m_pIDataInitialize; // MSDA Initialize object
  374. IDataConvert * m_pIDataConvert; // Data convert object
  375. CAsiObject * m_pSessions; // Sessions
  376. };
  377. ////////////////////////////////////////////////////////////////////////////////
  378. class CAsiSession: public CAsiSQLObject
  379. //
  380. // This class provides services of the SQL connection and session management.
  381. // Besides natural connection functionality (connect to and disconnect
  382. // from SQL environment), this class provides straightforward way of executing
  383. // transaction management and session management statements. Of course they
  384. // can be also executed as a ordinary SQL statements by means of prepare and
  385. // execute.
  386. //
  387. // MEMBER FUNCTIONS
  388. // ----------------
  389. //
  390. // Construction/Destruction
  391. //
  392. // CAsiSession (CAsiAppl *)
  393. //
  394. // CAsiSession constructor constructs SQL-session object, but doesn't start
  395. // the SQL session. Session is started when connecting to SQL environemnt
  396. // is performed by means of the Connect () method provided by this class.
  397. //
  398. // ~CAsiSession ()
  399. //
  400. // Destroy CAsiSession object. If SQL-session is active when destructor is
  401. // called, then terminate current transaction by ROLLBACK.
  402. //
  403. //
  404. // Starting/Terminating Session
  405. //
  406. // EAsiBoolean Connect (
  407. // const CAsiUcStr & LinkFile, // Link File name
  408. // const CAsiUcStr & usrname, // User name
  409. // const CAsiUcStr & password, // Password
  410. // EAsiBoolean fPrompt) // Prompt
  411. //
  412. // Connect ot OLEDB data source via OLEDB provider.
  413. // This function can throw exception and sets complition condition.
  414. // Return kAsiTrue if succeeded and kAsiFalse otherwise.
  415. //
  416. //
  417. // EAsiBoolean Disconnect (void)
  418. //
  419. // Terminate SQL session and disconnect from SQL environment if there is
  420. // mo active transaction associated with the session. Otherwise throw
  421. // exception condition (if ASI_TRY was established), and store complition
  422. // condition.
  423. //
  424. //
  425. // Setting Session Context
  426. //
  427. // The function listed below are provided to set context of the current
  428. // SQL session. Session context items that can be set by means of them
  429. // comprise the following items:
  430. //
  431. // catalog name,
  432. // schema name,
  433. // character set name,
  434. // time zone displacement, and
  435. // authorization
  436. //
  437. // These function can throw ASI exception and set complition condition.
  438. // They return kAsiTrue if succeeded and kAsiFalse otherwise.
  439. //
  440. // EAsiBoolean SetCatalog (
  441. // const CAsiUcStr & catalog) // Catalog name
  442. //
  443. // EAsiBoolean SetSchema (
  444. // const CAsiUcStr & schema) // Schema name
  445. //
  446. // EAsiBoolean SetNames (
  447. // const CAsiUcStr & name) // Character set name
  448. //
  449. // EAsiBoolean SetTimeZone (
  450. // const CAsiDT &timezone) // Time Zone
  451. //
  452. // EAsiBoolean SetAuthor (
  453. // const CAsiUcStr & user); // Authorization
  454. //
  455. //
  456. // Transaction management
  457. //
  458. // EAsiBoolean SetTrans (
  459. // EAsiTILevel ilevel, // Isolation level
  460. // EAsiTMode tmpode, // Transaction mode
  461. // uint size // Diagnostics area size
  462. // )
  463. // Set transaction isolation level and transaction mode for the
  464. // next transaction. If transaction is currently active, then throw ASI
  465. // exception. Store complition condition.
  466. //
  467. //
  468. // EAsiBoolean DeferrConstr (
  469. // CAsiIdent *consname) // Constraint name
  470. //
  471. // Change constraint checking mode to deffered.
  472. //
  473. // EAsiBoolean ImmConstr (
  474. // const CAsiIdent &consname) // Constraint name
  475. //
  476. // Change constraint checking mode to immediate
  477. //
  478. // EAsiBoolean Commit (void); // Commit work
  479. //
  480. // Terminate transaction by commit
  481. //
  482. // EAsiBoolean Rollback (void); // Rollback
  483. //
  484. // Terminate transaction by rollback
  485. //
  486. //
  487. {
  488. friend class CAsiStm;
  489. friend class CAsiCsr;
  490. friend class CAsiExecStm;
  491. friend class CAsiAppl;
  492. friend class CAsiCsrTable;
  493. friend class CAsiCsrInfSchema;
  494. friend class CAsiCsrRegTable;
  495. public:
  496. // Construction/Destruction
  497. //
  498. CAsiSession (CAsiAppl *);
  499. virtual ~CAsiSession ();
  500. // Starting/Terminating Session
  501. //
  502. EAsiBoolean Connect (const CAsiUcStr & LinkFile,
  503. const CAsiUcStr & Username,
  504. const CAsiUcStr & Password,
  505. EAsiBoolean fPrompt = kAsiFalse);
  506. EAsiBoolean ConnectIniString (const CAsiUcStr & IniString);
  507. EAsiBoolean GetConnectionString (CAsiUcStr *);
  508. EAsiBoolean Disconnect (void);
  509. // Setting Session Context
  510. //
  511. EAsiBoolean SetCatalog (const CAsiUcStr &);
  512. EAsiBoolean SetSchema (const CAsiUcStr &);
  513. EAsiBoolean SetNames (const CAsiUcStr &);
  514. EAsiBoolean SetTimeZone (const CAsiDT &);
  515. EAsiBoolean SetTimeZone (void); // Set local time zone
  516. EAsiBoolean SetAuthor (const CAsiUcStr &);
  517. // Transaction management
  518. //
  519. EAsiBoolean SetTrans (EAsiTILevel, EAsiTMode, uint dSize = 64); // Set transaction
  520. EAsiBoolean DeferrConstr (CAsiIdent * cnst = 0); // Deffer constraint
  521. EAsiBoolean ImmConstr (CAsiIdent * cnst = 0); // Immediate constraint
  522. EAsiBoolean Commit (void); // Commit work
  523. EAsiBoolean Rollback (void); // Rollback
  524. // Misceleneous
  525. //
  526. const CAsiUcStr & Name (void) const; // Session/connection name
  527. virtual EAsiBoolean GetStatus (EAsiStatInfo, ULONG_PTR *); // Get check status
  528. protected:
  529. EAsiBoolean Disconnect (CAsiObject *);
  530. EAsiBoolean GetCatalog (CAsiUcStr *);
  531. private:
  532. virtual CAsiObject * duplicate (void) const; // Duplicate
  533. EAsiBoolean CreateSession (IDBInitialize *);
  534. EAsiBoolean Execute (const CAsiUcStr &); // Execute command
  535. EAsiBoolean CheckForNotNull (EAsiInfSchTab, int);
  536. EAsiBoolean CanRetrieveCatalogs (void);
  537. EAsiBoolean CanRetrieveSchemas (void);
  538. void GetProviderTypes (void);
  539. EAsiBoolean GetStatusInfo ();
  540. void AttachStm (CAsiExecStm *);
  541. void DetachStm (CAsiExecStm *);
  542. void DetachAllStm (void);
  543. void DeallocateAllStm (void);
  544. void AttachCsr (CAsiCsr *);
  545. void DetachCsr (CAsiCsr *);
  546. void DetachAllCsr (void);
  547. EAsiBoolean HasOpenedObjects (void);
  548. private:
  549. CAsiAppl * m_pAppl; // Aplication
  550. CAsiUcStr m_LinkFileName ; // Link file name
  551. CAsiUcStr m_ConnectionString; // Connection string from provider
  552. IUnknown * m_pISession; // Session
  553. CAsiUcStr m_ucCatalog; // Current catalog
  554. ULONG m_BLOBStorage; // Only if BLOBs supported;
  555. CAsiList * m_pStms; // statements
  556. CAsiList * m_pCsrs; // cursors
  557. };
  558. ////////////////////////////////////////////////////////////////////////////////
  559. class CAsiStm: public CAsiSQLObject
  560. //
  561. // This class introduces functionality of the SQL statement descriptors
  562. // Basic categories of services provided by this class are listed below:
  563. // - Input parameters manipulation (bind buffers)
  564. // - Output parameter manipulation (resulting columns)
  565. //
  566. // MEMBER FUNCTIONS
  567. // ----------------
  568. //
  569. // Construction/Destruction
  570. //
  571. // CAsiStm (void)
  572. //
  573. // Allocate SQL statement descriptor.
  574. //
  575. // virtual ~CAsiStm (void);
  576. //
  577. // Destroy statement descriptor.
  578. //
  579. //
  580. // Input Parameters Manipulation
  581. //
  582. // int ParamQty (void)
  583. //
  584. // Return number of input parameters (bind variables) in the original
  585. // SQL statement. Number of parameter becomes available after SQL statement
  586. // was prepared.
  587. //
  588. //
  589. // CAsiParameter * ParamDsc (
  590. // int ipar // Parameter number
  591. // ) const
  592. //
  593. // Get parameter descriptor. ipar shall be greater than or equal to 0 and
  594. // less than number of parameters returned by the ParamQty ().
  595. // If wrong parameter number was specified return 0 instead of pointer to it.
  596. //
  597. //
  598. // Bind parameter with host buffer
  599. //
  600. // EAsiBoolean Bind ( ... )
  601. //
  602. // Two basic methods for binding input paramters with the host variable
  603. // buffers are provided by the CAsiStm class. They are
  604. //
  605. // - by parameter number
  606. // - by parameter name
  607. //
  608. // Input parameter is bound with CAsiData object
  609. //
  610. //
  611. // Output Column Descriptors / Column Values
  612. //
  613. // This set of services are provided in order to get description and
  614. // values of the resulting columns for the single row select statement
  615. // and cursor. For other types of statements these services have no sence
  616. // and always return kAsiBad.
  617. //
  618. // int ColQty (void) const
  619. //
  620. // Return number of columns in resuting rowset.
  621. //
  622. //
  623. // CAsiColumn *ColDsc (
  624. // int colnum // Column number
  625. // ) const;
  626. //
  627. // Return pointer to descripttor of the specified column.
  628. //
  629. //
  630. // Two basic methods are provided to retrieve values of the resulting
  631. // columns:
  632. //
  633. // - bind output column with the host buffer, and
  634. // - retrieve column value from descriptor
  635. //
  636. // These two methods are incompatible, i.e. if one method is used, another
  637. // is not allowed.
  638. //
  639. // Both methods are simular and allow to store output value into
  640. // CAsiData object
  641. //
  642. // EAsiBoolean Sob ( ... )
  643. //
  644. // Bind output column with the host program buffer
  645. //
  646. //
  647. // EAsiBoolean Cvl (...)
  648. //
  649. // Retrieve column data from descriptor
  650. //
  651. //
  652. {
  653. friend class CAsiSession;
  654. public:
  655. // Construction/Destruction
  656. //
  657. CAsiStm (void);
  658. virtual ~CAsiStm (void);
  659. // Init parrent session
  660. //
  661. void SetSession (CAsiSession *);
  662. // Input Parameters Manipulation
  663. //
  664. virtual int ParamQty (void) const; // Parameter quantity
  665. virtual CAsiParameter * ParamDsc (int) const; // Get parameter descriptor
  666. // Bind input parameter by number with
  667. //
  668. virtual EAsiBoolean Bind (int, CAsiData *); // CAsiData object
  669. virtual EAsiBoolean Bind (int, void *, short *,
  670. int, EAsiHostType); // Host buffer
  671. // Bind input parameter by name with
  672. //
  673. virtual EAsiBoolean Bind (const CAsiIdent &, CAsiData *); // CAsiData object
  674. virtual EAsiBoolean Bind (const CAsiIdent &, void *, short *,
  675. int, EAsiHostType); // Host buffer
  676. // Output Column Descriptors / Column Values
  677. //
  678. //
  679. virtual int ColQty (void) const; // Column quantity
  680. virtual CAsiColumn * ColDsc (int) const; // Get column descriptor
  681. // Bind output parameter (column) with
  682. virtual EAsiBoolean Sob (int, CAsiData *); // CAsiData object
  683. virtual EAsiBoolean Sob (int, void *, short *,// Host buffer
  684. int, EAsiHostType);
  685. // Retrieve value of output parameter (column) into
  686. virtual EAsiBoolean Cvl (int, CAsiData *); // CAsiData object
  687. virtual EAsiBoolean Cvl (int, void *, short *,// Host buffer
  688. int, EAsiHostType);
  689. protected:
  690. EAsiBoolean CvlInt (int, CAsiData *) const; // CAsiData object
  691. EAsiBoolean pInput (void);
  692. EAsiBoolean InitColsDsc ();
  693. protected:
  694. CAsiBinding * m_pInput; // Input bindings
  695. CAsiBinding * m_pOutput; // Output buffers
  696. CAsiSession * m_pSession; // Where I was allocated
  697. // Column descriptors buffer
  698. ULONG_PTR m_lColNumber;
  699. DBCOLUMNINFO * m_pColumnInfo;
  700. OLECHAR * m_pStringBuff;
  701. CAsiRow * m_pAsiRow;
  702. };
  703. ////////////////////////////////////////////////////////////////////////////////
  704. class CAsiExecStm: public CAsiStm
  705. //
  706. // This class introduces functionality of the executable SQL statement.
  707. // Another type of statement is a cursor that can't be executed, and
  708. // should be opend.
  709. // Basic categories of services provided by this class are listed below:
  710. // - Statement preparing
  711. // - Statement execution
  712. //
  713. // MEMBER FUNCTIONS
  714. // ----------------
  715. //
  716. // Construction/Destruction
  717. //
  718. // CAsiExecStm (void)
  719. //
  720. // Constructs SQL statement object
  721. //
  722. // virtual ~CAsiExecStm (void);
  723. //
  724. // Destroy statement. If statement was not deallocated explicitly by
  725. // means of Dealocate method, then statement is deallocated implicitly.
  726. //
  727. //
  728. // Preparing/Deallocating
  729. //
  730. // EAsiBoolean Prepare (
  731. // CAsiSession *session, // Session
  732. // const CAsiUcStr & stm, // Statement
  733. // EAsiBoolean trans = kAsiTrue // translation flag.
  734. // )
  735. // Prepare standard SQL statement. Associate
  736. // SQL statement with the session and prepares it. If trans parameter is true, ASI
  737. // performs translation into DBMS nastive format.
  738. // This function stores complition condtion and
  739. // throws ASI exception if error condition was encounted.
  740. //
  741. // EAsiBoolean Deallocate (void)
  742. //
  743. // Deallocate either standard or interdatabase SQL statement. If statement is
  744. // a cursor specification associated with cursor in the open state, then
  745. // ASI exception is raised.
  746. //
  747. //
  748. // Execute statement
  749. //
  750. // EAsiBoolean Execute (void)
  751. //
  752. // Execute prepared SQL statement. Complition condition is always set and
  753. // ASI exception can be thrown.
  754. //
  755. //
  756. // Immediate SQL and Native statement execution
  757. //
  758. // EAsiBoolean ImmediateExecute (
  759. // CAsiSession *session, // session
  760. // const CAsiUcStr & stm) // SQL statement
  761. //
  762. // Immediate execute standard SQL statement
  763. // Successful execution results is returning kAsiGood. If execution fails,
  764. // then ASI exception is thrown, complition
  765. // conditon is stored CAsiSQLObject and kAsiBad is returned. Execution
  766. // of this statement can start transaction.
  767. //
  768. {
  769. friend class CAsiCsr;
  770. friend class CAsiSession;
  771. public:
  772. // Construction/Destruction
  773. //
  774. CAsiExecStm (void);
  775. virtual ~CAsiExecStm (void);
  776. virtual EAsiBoolean IsRowset (void) const;
  777. // Preparing/Deallocating
  778. //
  779. virtual EAsiBoolean Prepare (CAsiSession *,
  780. const CAsiUcStr &,
  781. EAsiBoolean trans = kAsiTrue);
  782. virtual EAsiBoolean Deallocate (void); // Deallocate statement
  783. // Prepared and execute statement (immediate execution)
  784. //
  785. virtual EAsiBoolean Execute (void);
  786. virtual EAsiBoolean ImmediateExecute (CAsiSession *,
  787. const CAsiUcStr &,
  788. EAsiBoolean trans = kAsiTrue);
  789. EAsiBoolean Cancel (void); // Cancel execution of SQL statment
  790. // Input Parameters Manipulation
  791. //
  792. virtual int ParamQty (void) const; // Parameter quantity
  793. virtual CAsiParameter * ParamDsc (int) const; // Get parameter descriptor
  794. virtual EAsiBoolean Bind (int, CAsiData *);
  795. virtual EAsiBoolean Bind (int, void *, short *, int, EAsiHostType);
  796. virtual EAsiBoolean Bind (const CAsiIdent &, CAsiData *);
  797. virtual EAsiBoolean Bind (const CAsiIdent &, void *, short *, int, EAsiHostType);
  798. virtual int ColQty (void) const;
  799. virtual CAsiColumn * ColDsc (int) const;
  800. virtual EAsiBoolean GetStatus (EAsiStatInfo, ULONG_PTR *); // Get check status
  801. private:
  802. virtual CAsiObject * duplicate (void) const;
  803. EAsiBoolean Prepare (void);
  804. EAsiBoolean IsPrepared (void) const;
  805. void AttachCsr (CAsiCsr *);
  806. void DetachCsr (CAsiCsr *);
  807. void DetachAllCsr (void);
  808. void CloseAllCsr (void);
  809. protected:
  810. ICommandText * m_pICommand; // Command
  811. // Parameter descriptors buffer
  812. ULONG m_lParNumber;
  813. DBPARAMINFO * m_pParamInfo;
  814. OLECHAR * m_pStringBuffParam;
  815. // cursors
  816. CAsiList * m_pCsrs;
  817. };
  818. ////////////////////////////////////////////////////////////////////////////
  819. class CAsiCsr: public CAsiStm
  820. //
  821. // This class proivides functionality of cursor
  822. //
  823. // Construction/Destruction
  824. //
  825. // CAsiCsr (void);
  826. //
  827. // Construct cusror object
  828. //
  829. // ~CAsiCsr (void);
  830. //
  831. // Destroy cursor object. If cursor was in open state, close cursor implicitly.
  832. //
  833. //
  834. // Allocate/Deallocate Cursor
  835. //
  836. //
  837. // EAsiBoolean Allocate (
  838. // CAsiExecStm * statement, // Prepared cursor specification
  839. // const CAsiIdent & name, // Cursor name
  840. // EAsiCurScr Scrollability, // Cursor Scrollability
  841. // EAsiCurSns Sensivity); // Cursor Sensitivity
  842. //
  843. // Allocate cursor. Statement shall be a prepared cursor specification.
  844. // Otherwise ASI exception is thrown.
  845. //
  846. //
  847. //
  848. // Open/Close Cursor
  849. //
  850. // EAsiBoolean Open (void)
  851. //
  852. // Open cursor. Cursor state becomes open and cursor position becomes before
  853. // the first row of the selection set.
  854. //
  855. //
  856. // EAsiBoolean Close (void)
  857. //
  858. // Close cursor. Cursor state is set to 'close'.
  859. //
  860. //
  861. // Fetching Resulting Rowset
  862. //
  863. // These services allow to fetch
  864. // - Next row
  865. // - Prior row
  866. // - First row
  867. // - Last row
  868. // - by the Relative row number (offset)
  869. // - by the Absolute row number (direct)
  870. //
  871. // EAsiBoolean Fetch (void)
  872. //
  873. // EAsiBoolean FetchPrior (void)
  874. //
  875. // EAsiBoolean FetchFirst (void)
  876. //
  877. // EAsiBoolean FetchLast (void)
  878. //
  879. // EAsiBoolean FetchRelative (
  880. // long rrow) // Relative row number
  881. //
  882. // EAsiBoolean FetchAbsolute (
  883. // long row) // Absolute row number
  884. //
  885. //
  886. // Storing Resulting Column Values
  887. //
  888. // CAsiRow * getCurrentRow (void)
  889. //
  890. // Return pointer to the CAsiRow object containing current row
  891. //
  892. //
  893. // Delete/Update Current Row (Delete: positioned, Update: positioned)
  894. //
  895. // EAsiBoolean Delete (void)
  896. //
  897. // Delete current row
  898. //
  899. //
  900. // EAsiBoolean Update (const CAsiRow &)
  901. //
  902. // Update current row. Only columns that are present in the CAsiRow
  903. // object are updated. Association is done by column name
  904. //
  905. //
  906. // Misceleneous
  907. //
  908. // EAsiBoolean is_updatable (void); // Is cursor updatable
  909. // EAsiBoolean is_scrollable (void); // Is cursor scrollable
  910. // EAsiBoolean is_open (void); // Is cursor in open state
  911. //
  912. {
  913. friend class CAsiExecStm;
  914. public:
  915. // Construction/Destruction
  916. //
  917. CAsiCsr (void);
  918. virtual ~CAsiCsr (void);
  919. // Allocate SQL Cursor
  920. EAsiBoolean Allocate (CAsiExecStm * csrspec,
  921. const CAsiIdent & csrname,
  922. EAsiCurScr sc = kAsiNonScroll, // Scrollability
  923. EAsiCurSns sn = kAsiSnsUndef, // Sensitivity
  924. EAsiBoolean upd = kAsiUnknown, // Updatbility
  925. EAsiBoolean fIns = kAsiFalse); // Inserts
  926. // Input Parameters Manipulation
  927. //
  928. virtual int ParamQty (void) const; // Parameter quantity
  929. virtual CAsiParameter * ParamDsc (int) const; // Get parameter descriptor
  930. virtual EAsiBoolean Bind (int, CAsiData *);
  931. virtual EAsiBoolean Bind (int, void *, short *, int, EAsiHostType);
  932. virtual EAsiBoolean Bind (const CAsiIdent &, CAsiData *);
  933. virtual EAsiBoolean Bind (const CAsiIdent &, void *, short *, int, EAsiHostType);
  934. // Bind output parameter (column) with
  935. virtual EAsiBoolean Sob (int, CAsiData *);
  936. virtual EAsiBoolean Sob (int, void *, short *, int, EAsiHostType);
  937. // Open/Close Cursor
  938. virtual EAsiBoolean Open (void); // Open cursor
  939. virtual EAsiBoolean Close (void); // Close
  940. EAsiBoolean Cancel (void); // Cancel cursor open
  941. // Fetching Resulting Rowset
  942. //
  943. virtual EAsiBoolean Fetch (void); // Fetch next row
  944. virtual EAsiBoolean FetchPrior (void); // Fetch Prior row
  945. virtual EAsiBoolean FetchFirst (void); // Fetch First row
  946. virtual EAsiBoolean FetchLast (void); // Fetch Last row
  947. virtual EAsiBoolean FetchRelative (long); // Fetch Relative row
  948. virtual EAsiBoolean FetchAbsolute (long); // Fetch Absolute row
  949. virtual EAsiBoolean CheckCCondition (CAsiData **);
  950. // Storing Resulting Column Values
  951. //
  952. CAsiRow * getCurrentRow (void); // Get pointer to current row
  953. // Delete/Update Current Row (Delete: positioned, Update: positioned)
  954. //
  955. virtual EAsiBoolean Delete (void); // Delete current row
  956. virtual EAsiBoolean Update (const CAsiRow &); // Update current row
  957. // Insert row
  958. virtual EAsiBoolean Insert (const CAsiRow &);
  959. virtual EAsiBoolean Insert (void); // Default row
  960. virtual int ColQty (void) const;
  961. virtual CAsiColumn * ColDsc (int) const;
  962. virtual EAsiBoolean Cvl (int, CAsiData *);
  963. virtual EAsiBoolean Cvl (int, void *, short *,
  964. int, EAsiHostType);
  965. // Misceleneous
  966. //
  967. virtual EAsiBoolean GetStatus (EAsiStatInfo, ULONG_PTR *); // Get check status
  968. virtual EAsiBoolean IsRowset (void) const;
  969. virtual EAsiBoolean is_updatable (void) const; // Is cursor updatable
  970. virtual EAsiBoolean is_insertable (void) const; // Can insert rows
  971. virtual EAsiBoolean is_scrollable (void) const; // Is cursor scrollable
  972. virtual EAsiBoolean is_insensitive (void) const; // Is cursor insensitive
  973. virtual EAsiBoolean is_open (void) const; // Is cursor in open state
  974. virtual EAsiCurPos position (void) const; // Cursor position
  975. private:
  976. virtual CAsiObject * duplicate (void) const;
  977. protected:
  978. EAsiBoolean InitOutputBind ();
  979. EAsiBoolean MakeCursorProp (DBPROPSET * pRowsetPropSet);
  980. EAsiBoolean QueryCursorProp (void);
  981. EAsiBoolean SobValues (void);
  982. EAsiBoolean Svl (int);
  983. EAsiBoolean ReadData (void);
  984. EAsiBoolean GetColValue (int, CAsiData *);
  985. EAsiBoolean StoreValueFromDBType(CAsiData *, DBTYPE, void *);
  986. EAsiBoolean InitAccessor (ULONG_PTR, DBCOLUMNINFO *, const CAsiRow &,
  987. ULONG *, DBBINDING **, HACCESSOR *,
  988. EAsiBoolean);
  989. EAsiBoolean DoChangeErrors (HRESULT hr, ULONG, DBBINDING *);
  990. EAsiBoolean UpdateRow (ULONG_PTR, DBCOLUMNINFO *, const CAsiRow &);
  991. EAsiBoolean InsertRow (ULONG_PTR, DBCOLUMNINFO *, const CAsiRow &);
  992. protected:
  993. CAsiExecStm * m_pCursorSpec; // Pointer to cursor spec
  994. IRowset * m_pIRowset; // Rowset object
  995. IRowsetChange * m_pIRowsetChange;
  996. IRowsetLocate * m_pIRowsetLocate;
  997. IAccessor * m_pIAccessor;
  998. HACCESSOR m_hAccessor;
  999. DWORD_PTR m_lRowCount;
  1000. DWORD m_lCurrRow;
  1001. IDataConvert * m_pIDataConvert; // Data convert object
  1002. HROW * m_rghRows;
  1003. BYTE * m_pData;
  1004. // Output bindings
  1005. DWORD_PTR m_dwOffset;
  1006. DBBINDING * m_rgBind;
  1007. int m_iNumBind;
  1008. EAsiBoolean m_fDataRead; // Data read flag
  1009. EAsiBoolean m_fBlkStorObj; // Bloking storage objects
  1010. EAsiBoolean m_fBLOBExpected;// Blobs in recordset
  1011. IUnknown * m_pIUnknown; // only one blob per cusrsor.
  1012. // release it when next row is fetched
  1013. CAsiIdent m_CsrName; // cursor name
  1014. EAsiCurScr m_ScrFlag; // Scrollability flag
  1015. EAsiCurSns m_SnsFlag; // Sensitivity flag
  1016. EAsiBoolean m_fUpd; // Updatability flag
  1017. EAsiBoolean m_fIns; // Inserts flag
  1018. EAsiBoolean m_fOwnInserts; // Own inserts
  1019. EAsiBoolean m_fOwnUpdates; // Own Updates
  1020. EAsiBoolean m_fIsOpen; // Is open flag
  1021. EAsiCurPos m_CsrPos; // Cursor position
  1022. // Info for scrollable cursors:
  1023. ULONG_PTR m_ulColumns;
  1024. ULONG m_ulCurrentRowNo;
  1025. ULONG m_ulMaxRowNo;
  1026. ULONG m_ulRows;
  1027. // For CAsiCsrTable based classes:
  1028. CAsiTCCond * m_pTCCond;
  1029. };
  1030. ////////////////////////////////////////////////////////////////////////////
  1031. class CAsiCsrTable : public CAsiCsr
  1032. //
  1033. // This class provides access to database data on a table level. It is derived from
  1034. // the CAsiCsr class and inherits all its functionality. It is superclass for all
  1035. // ASI classes that provides access to data on a table level, such as Regular Table
  1036. // Cursor (CAsiCsrRegTable) and Information Schema Table Cursor (CAsiCsrInfSchema) and
  1037. // Data Source Enumerator (CAsiEnumerator) .
  1038. {
  1039. public:
  1040. CAsiCsrTable (void);
  1041. virtual ~CAsiCsrTable (void);
  1042. virtual int ColQty (void) const;
  1043. virtual CAsiColumn * ColDsc (int) const;
  1044. virtual EAsiBoolean Open (void);
  1045. virtual EAsiBoolean Close (void);
  1046. virtual EAsiBoolean Update (const CAsiRow &);
  1047. virtual EAsiBoolean Cvl (int, CAsiData *);
  1048. virtual EAsiBoolean Cvl (int, void *, short *,
  1049. int, EAsiHostType);
  1050. virtual EAsiBoolean SetFilter (CAsiTCCond *);
  1051. virtual EAsiBoolean SetOrder ();
  1052. protected:
  1053. void DeallocCsr (void);
  1054. protected:
  1055. };
  1056. ////////////////////////////////////////////////////////////////////////////
  1057. class CAsiCsrRegTable : public CAsiCsrTable
  1058. // Regular table cursor. It is derived from CAsiCsrTable class and inherits all
  1059. // its functionality. Method Allocate provides functionality for allocating Regular
  1060. // table rowset. Rows of the table must be accessed by mean regular cursor navigating
  1061. // and modification methods.
  1062. {
  1063. public:
  1064. CAsiCsrRegTable (void);
  1065. virtual ~CAsiCsrRegTable (void);
  1066. // Database table
  1067. EAsiBoolean Allocate (CAsiSession * ses,
  1068. const CAsiUcStr & catalog,
  1069. const CAsiUcStr & schema,
  1070. const CAsiUcStr & table,
  1071. EAsiCurScr sc = kAsiNonScroll, // Scrollability
  1072. EAsiBoolean upd = kAsiUnknown // Updatbility
  1073. );
  1074. protected:
  1075. CAsiUcStr m_pCatalog ;
  1076. CAsiUcStr m_pSchema;
  1077. CAsiUcStr m_pName;
  1078. };
  1079. ////////////////////////////////////////////////////////////////////////////
  1080. class CAsiCsrInfSchema : public CAsiCsrTable
  1081. // Infomation schema table cursor. It is derived from CAsiCsrTable class and inherits all
  1082. // its functionality. Method Allocate provides functionality for allocating information
  1083. // schema table rowset. Rows of the table must be accessed by mean regular cursor navigating
  1084. // methods. Information Schema cursor is a read only cursor.
  1085. {
  1086. public:
  1087. CAsiCsrInfSchema (void);
  1088. virtual ~CAsiCsrInfSchema (void);
  1089. // allocate INFORMATION_SCHEMA cursor
  1090. EAsiBoolean Allocate (CAsiSession * ses,
  1091. EAsiInfSchTab ischema,
  1092. EAsiCurScr sc = kAsiNonScroll // Scrollability
  1093. );
  1094. protected:
  1095. EAsiInfSchTab m_istType;
  1096. };
  1097. ////////////////////////////////////////////////////////////////////////////
  1098. class CAsiEnumerator: public CAsiCsrTable
  1099. // Enumerator class provides services to enumerate Providers and Databases
  1100. // supported by Providers. CAsiEnumerator is build upon rowset ISourcesRowset
  1101. // object. It inherits all functionality of CAsiCsr class. Enumerator is a read only
  1102. // cursor.
  1103. {
  1104. public:
  1105. CAsiEnumerator (void);
  1106. virtual ~CAsiEnumerator (void);
  1107. EAsiBoolean Allocate (CAsiAppl *);
  1108. EAsiBoolean Allocate (CAsiAppl *, CLSID & clsidEnum);
  1109. // Set restriction
  1110. // Data Source Type (EAsiDataSourceType)
  1111. // kAsiDSSOURCETYPE_DATASOURCE
  1112. // kAsiDSSOURCETYPE_ENUMERATOR
  1113. // kAsiDSSOURCETYPE_BOTH
  1114. // Name of data source or enumerator
  1115. // NULL - not restricted
  1116. // Is Parent
  1117. void SetFilter (EAsiDataSourceType dst,
  1118. const CAsiUcStr & pName,
  1119. EAsiBoolean isParent = kAsiUnknown);
  1120. virtual EAsiBoolean Fetch (void);
  1121. protected:
  1122. CLSID m_clsidEnum;
  1123. EAsiDataSourceType m_eDsType;
  1124. CAsiUcStr m_pName;
  1125. EAsiBoolean m_fIsParent;
  1126. };
  1127. /////////////////////////////////////////////////////////////////////////
  1128. class CAsiTACond: public CAsiObject
  1129. //
  1130. // This class represents atomic condition for the table cursor in the
  1131. // low-level driver.
  1132. //
  1133. {
  1134. friend class CAsiTCCond;
  1135. public:
  1136. CAsiTACond (void);
  1137. CAsiTACond (const CAsiTACond &);
  1138. virtual ~CAsiTACond (void);
  1139. virtual CAsiObject * duplicate (void) const;
  1140. CAsiData * m_pData; // Pointer to internal data object
  1141. int m_cColnum; // Column number
  1142. EAsiCompType m_CompOp; // Comparision predicate
  1143. };
  1144. /////////////////////////////////////////////////////////////////////
  1145. class CAsiTCCond: public CAsiObject
  1146. //
  1147. // This class is used to represent Database Table Cursor condition
  1148. // Actually this class is an array of the atomic conditions CAsiACond,
  1149. // which are assumed to be ANDed. This class is passed to the AllocCsr
  1150. // member function of the CAsiTable class and is used to filter table data
  1151. // during fetching.
  1152. //
  1153. {
  1154. public:
  1155. CAsiTCCond (void);
  1156. CAsiTCCond (int);
  1157. CAsiTCCond (const CAsiTCCond &);
  1158. virtual ~CAsiTCCond (void);
  1159. // Manipulation
  1160. int Count (void) const; // Number of items
  1161. void Append (const CAsiTACond &); // Append item
  1162. // Operators
  1163. CAsiTACond & operator [] (int); // Get reference to item
  1164. virtual CAsiObject * duplicate (void) const;
  1165. private:
  1166. int m_cQnty; // Number of conditions
  1167. CAsiList m_Conds; // Conditions
  1168. };
  1169. ////////////////////////////////////////////////////////////////////////////////////////
  1170. //
  1171. // Helper functions
  1172. //
  1173. ////////////////////////////////////////////////////////////////////////////////////////
  1174. // Allocate Enumerator over a Data Source
  1175. // pAppl - pointer to initialized ASI application
  1176. // guidEnum - pointer to data source parent enumerator. If NULL, assume
  1177. // OLEDB root enumerator (CLSID_OLEDB_ENUMERATOR)
  1178. // pDS - Data Source name to enumerate
  1179. // pEnum - pointer to memory location where to store CAsiEnumerator.
  1180. // 0 if cannot enumerate.
  1181. //
  1182. // returns kAsiFalse, if enumerator cannot be allocated
  1183. //
  1184. EAsiBoolean AsiAllocateDSEnumerator (
  1185. CAsiAppl * pAppl, // [in] Asi Application
  1186. const GUID * guidEnum, // [in] Parent enumerator CLSID
  1187. const CAsiUcStr & pDS, // [in] DS name
  1188. CAsiEnumerator ** pEnum // [out] returned enumerator
  1189. );
  1190. ////////////////////////////////////////////////////////////////////////////////////////
  1191. // Get Enumerator CLSID over a data source
  1192. //
  1193. // Analogous to the AsiAllocateDSEnumerator. Returns enumerator CLSID, which
  1194. // can be used to Allocate CAsiEnumerator
  1195. //
  1196. EAsiBoolean AsiGetDSEnumerator (
  1197. CAsiAppl * pAppl, // [in] ASI Application
  1198. const GUID * guidEnum, // [in] Parent enumerator CLSID
  1199. const CAsiUcStr & pDS, // [in] DS name
  1200. GUID * guidDsEnum // [out] enumerator CLSID
  1201. );
  1202. ////////////////////////////////////////////////
  1203. // Extern function prototypes
  1204. //
  1205. extern "C" {
  1206. void AsiExceptionThrow (CAsiException*);
  1207. }
  1208. #pragma pack (pop)
  1209. #endif /* ASI_ASICLASS_HH */
  1210. /*EOF*/