home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cppsql.zip / SQLSRC.ZIP / SQL.HPP < prev    next >
Text File  |  1992-09-18  |  10KB  |  332 lines

  1. // :H1 sql.hpp: START OF SPECIFICATIONS
  2. //----------------------------------------------------------------------
  3. //
  4. //  Module Name: SQL.HPP
  5. //
  6. //  Description: SQL Interface.
  7. //
  8. //  Product Classification:
  9. //    IBM Internal Use Only
  10. //    (C) Copyright IBM Corp. 1992
  11. //
  12. //  Status: New
  13. //
  14. //  Initial Author: George L. Havens
  15. //
  16. //  Function: To provide an interface to SQL databases.
  17. //
  18. //  Notes: None.
  19. //
  20. //  Dependencies: Requires PORTABLE.H include.
  21. //
  22. //  Restrictions: None.
  23. //
  24. //  Compiler: Zortech C++
  25. //
  26. // Change Activity -----------------------------------------------------
  27. //
  28. // $MOD(module) COMP(component) PROD(product): Description...
  29. //
  30. // FLAG  REASON  VERS  DATE  WHO   DESCRIPTION
  31. // ---- -------- ---- ------ ---   -----------
  32. //               V100 920224 GLH : Initial level
  33. // $P1  P0001979 V100 920608 GLH : Fix problems caused when start database 
  34. //                                 started from application
  35. //
  36. // END-OF-SPECIFICATIONS -----------------------------------------------
  37.  
  38. #ifndef XX_SQL
  39. #define XX_SQL
  40. class SQL
  41.   {
  42.     public:
  43. //----------------------------------------------------------------------
  44. //
  45. //  Function Name: SQL constructor
  46. //
  47. //  Purpose: This method is the SQL object constructor.
  48. //
  49. //  Description: This method will save the name of the database.
  50. //
  51. //  Input:
  52. //    name       database name to be used
  53. //    access     access is SHARED or EXCLUSIVE, default is SHARED
  54. //    drive      drive to create database on
  55. //
  56. //  Output:
  57. //    none
  58. //
  59. //----------------------------------------------------------------------
  60.       SQL (const CHAR *name, CHAR access = 'S', CHAR drive = 0);
  61.            #define SHARE 'S'                              // shared access
  62.            #define EXCLUSIVE 'X'                          // exclusive access
  63. //----------------------------------------------------------------------
  64. //
  65. //  Function Name: Create
  66. //
  67. //  Purpose: This method creates an SQL database.
  68. //
  69. //  Description: This method creates an SQL database. The database must still
  70. //               be opened to be used.
  71. //
  72. //  Input:
  73. //    comment    comment to be placed into database
  74. //    bind_path  path for SQL bind file
  75. //
  76. //  Output:
  77. //    return code 0 = successful, not 0 = error
  78. //
  79. //----------------------------------------------------------------------
  80.       SHORT Create (const CHAR *comment = "", const CHAR *bind_path = ".");
  81. //----------------------------------------------------------------------
  82. //
  83. //  Function Name: Open
  84. //
  85. //  Purpose: This method opens an SQL database.
  86. //
  87. //  Description: This method attempts to open an SQL database.
  88. //
  89. //  Input:
  90. //    none
  91. //
  92. //  Output:
  93. //    return code 0 = successful, not 0 = error
  94. //
  95. //----------------------------------------------------------------------
  96.       SHORT Open (VOID);
  97. //----------------------------------------------------------------------
  98. //
  99. //  Function Name: Close
  100. //
  101. //  Purpose: This method will close an SQL database.
  102. //
  103. //  Description: This method will close an SQL database.
  104. //
  105. //  Input:
  106. //    none
  107. //
  108. //  Output:
  109. //    return code 0 = successful, not 0 = error
  110. //
  111. //----------------------------------------------------------------------
  112.       SHORT Close (VOID);
  113. //----------------------------------------------------------------------
  114. //
  115. //  Function Name: Delete
  116. //
  117. //  Purpose: This method will delete an SQL database.
  118. //
  119. //  Description: This method will delete an SQL database.
  120. //
  121. //  Input:
  122. //    none
  123. //
  124. //  Output:
  125. //    return code 0 = successful, not 0 = error
  126. //
  127. //----------------------------------------------------------------------
  128.       SHORT Delete (VOID);
  129. //----------------------------------------------------------------------
  130. //
  131. //  Function Name: Get_buffer_size
  132. //
  133. //  Purpose: This method will get the buffer size for an SQL database.
  134. //
  135. //  Description: This method will get the size for the specified SQL database.
  136. //
  137. //  Input:
  138. //    size       size of buffer  
  139. //
  140. //  Output:
  141. //    return code 0 = successful, not 0 = error
  142. //
  143. //----------------------------------------------------------------------
  144.       SHORT Get_buffer_size (USHORT& size);
  145. //----------------------------------------------------------------------
  146. //
  147. //  Function Name: Set_buffer_size
  148. //
  149. //  Purpose: This method will set the buffer size for an SQL database.
  150. //
  151. //  Description: This method will set the size for the specified SQL database.
  152. //
  153. //  Input:
  154. //    size       size of buffer  
  155. //
  156. //  Output:
  157. //    return code 0 = successful, not 0 = error
  158. //
  159. //----------------------------------------------------------------------
  160.       SHORT Set_buffer_size (USHORT size);
  161. //----------------------------------------------------------------------
  162. //
  163. //  Function Name: Get_log_size
  164. //
  165. //  Purpose: This method will get the log file size for an SQL database.
  166. //
  167. //  Description: This method will get the size for the specified SQL database.
  168. //
  169. //  Input:
  170. //    size       size of log file
  171. //
  172. //  Output:
  173. //    return code 0 = successful, not 0 = error
  174. //
  175. //----------------------------------------------------------------------
  176.       SHORT Get_log_size (USHORT& size);
  177. //----------------------------------------------------------------------
  178. //
  179. //  Function Name: Set_log_size
  180. //
  181. //  Purpose: This method will set the log file size for an SQL database.
  182. //
  183. //  Description: This method will set the size for the specified SQL database.
  184. //
  185. //  Input:
  186. //    size       size of buffer  
  187. //
  188. //  Output:
  189. //    return code 0 = successful, not 0 = error
  190. //
  191. //----------------------------------------------------------------------
  192.       SHORT Set_log_size (USHORT size);
  193. //----------------------------------------------------------------------
  194. //
  195. //  Function Name: Get_log_number
  196. //
  197. //  Purpose: This method will get the number log files for an SQL database.
  198. //
  199. //  Description: This method will get the number of primary and seconday 
  200. //               log files.
  201. //
  202. //  Input:
  203. //    num_pri    number of primary log files
  204. //    num_sec    number of secondary log files
  205. //
  206. //  Output:
  207. //    return code 0 = successful, not 0 = error
  208. //
  209. //----------------------------------------------------------------------
  210.       SHORT Get_log_number (USHORT& num_pri, USHORT& num_sec);
  211. //----------------------------------------------------------------------
  212. //
  213. //  Function Name: Set_log_number
  214. //
  215. //  Purpose: This method will set the number log files for an SQL database.
  216. //
  217. //  Description: This method will set the number of primary and seconday 
  218. //               log files.
  219. //
  220. //  Input:
  221. //    num_pri    number of primary log files
  222. //    num_sec    number of secondary log files
  223. //
  224. //  Output:
  225. //    return code 0 = successful, not 0 = error
  226. //
  227. //----------------------------------------------------------------------
  228.       SHORT Set_log_number (USHORT num_pri, USHORT num_sec);
  229. //----------------------------------------------------------------------
  230. //
  231. //  Function Name: Commit
  232. //
  233. //  Purpose: This method will commit the changes to the database.
  234. //
  235. //  Description: This method will commit all the changes that have been
  236. //               made to the database.
  237. //
  238. //  Input:
  239. //    none
  240. //
  241. //  Output:
  242. //    return code 0 = successful, not 0 = error
  243. //
  244. //----------------------------------------------------------------------
  245.       SHORT Commit (VOID);
  246. //----------------------------------------------------------------------
  247. //
  248. //  Function Name: Rollback
  249. //
  250. //  Purpose: This method will rollback changes to the database.
  251. //
  252. //  Description: This method will rollback all the changes that have been      
  253. //               made to the database.
  254. //
  255. //  Input:
  256. //    none
  257. //
  258. //  Output:
  259. //    return code 0 = successful, not 0 = error
  260. //
  261. //----------------------------------------------------------------------
  262.       SHORT Rollback (VOID);
  263. //----------------------------------------------------------------------
  264. //
  265. //  Function Name: Error
  266. //
  267. //  Purpose: This method will return last method return code and
  268. //           location.
  269. //
  270. //  Description: This method will return the last method return code
  271. //               and location saved in private variables.
  272. //  Input:
  273. //    none
  274. //
  275. //  Output:
  276. //    rc_a    return code
  277. //    id_a    location of error
  278. //
  279. //----------------------------------------------------------------------
  280. inline VOID Error (SHORT& rc_a, SHORT& id_a)
  281.         {
  282.           // set current return code and location
  283.           rc_a = rc;
  284.           id_a = (rc == 0) ? 0 : id;
  285.         }
  286. //----------------------------------------------------------------------
  287. //
  288. //  Function Name: SQL destructor
  289. //
  290. //  Purpose: This method is the SQL object destructor.
  291. //
  292. //  Description: This method will free the database name, close
  293. //               the database, and stop the database manager.
  294. //
  295. //  Input:
  296. //    none
  297. //
  298. //  Output:
  299. //    none
  300. //
  301. //----------------------------------------------------------------------
  302.       ~SQL ();
  303.  
  304.     private:
  305.       CHAR    *database;               // database name
  306.       CHAR    use;                     // database use, SHARED or EXCLUSIVE
  307.       CHAR    build_drive;             // database build on drive
  308.       SHORT   rc;                      // return code for last operation
  309.       #define SQL_MEMORY_ERROR -10500
  310.       #define SQL_NAME_ERROR   -1001   // SQL error code
  311.       SHORT   id;                      // id of where last error occurred
  312. //    #define SQL_ID_1      1          // available for use            // @P1C
  313.       #define SQL_ID_2      2
  314.       #define SQL_ID_3      3         
  315.       #define SQL_ID_4      4
  316.       #define SQL_ID_5      5
  317. //    #define SQL_ID_6      6          // available for use
  318.       #define SQL_ID_7      7
  319.       #define SQL_ID_8      8
  320.       #define SQL_ID_9      9
  321.       #define SQL_ID_10     10
  322.       #define SQL_ID_11     11
  323.       #define SQL_ID_12     12
  324.       #define SQL_ID_13     13
  325.       #define SQL_ID_14     14
  326.       #define SQL_ID_15     15
  327.       #define SQL_ID_16     16
  328.       #define SQL_ID_17     17
  329.       #define SQL_ID_18     18
  330.   };
  331. #endif
  332.