loinfoW.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /***************************************************************************
  2. * Licensed Materials - Property of IBM and/or HCL
  3. *
  4. * IBM Informix Client-SDK
  5. *
  6. * Copyright IBM Corporation 1997, 2013 All rights reserved.
  7. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  8. *
  9. *
  10. *
  11. *
  12. *
  13. * Title: loinfoW.c (Unicode counterpart of loinfo.c)
  14. *
  15. * Description: To obtain information about a smart large object stored
  16. * in the database.
  17. * The folowing information will be obtained -
  18. * 1. Size of the smart large object
  19. * 2. Name of the sbspace where it is stored
  20. *
  21. ***************************************************************************
  22. */
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #ifndef NO_WIN32
  27. #include <io.h>
  28. #include <windows.h>
  29. #include <conio.h>
  30. #endif /*NO_WIN32*/
  31. #include "infxcli.h"
  32. #define BUFFER_LEN 25
  33. #define BUFFER_LENW 120
  34. #define ERRMSG_LEN 200
  35. SQLWCHAR defDsnW[] = L"odbc_demo";
  36. SQLCHAR defDsn[] = "odbc_demo";
  37. SQLINTEGER checkError (SQLRETURN rc,
  38. SQLSMALLINT handleType,
  39. SQLHANDLE handle,
  40. SQLCHAR* errmsg)
  41. {
  42. SQLRETURN retcode = SQL_SUCCESS;
  43. SQLSMALLINT errNum = 1;
  44. SQLWCHAR sqlStateW[6];
  45. SQLCHAR *sqlState;
  46. SQLINTEGER nativeError;
  47. SQLWCHAR errMsgW[ERRMSG_LEN];
  48. SQLCHAR *errMsg;
  49. SQLSMALLINT textLengthPtr;
  50. if ((rc != SQL_SUCCESS) && (rc != SQL_SUCCESS_WITH_INFO))
  51. {
  52. while (retcode != SQL_NO_DATA)
  53. {
  54. retcode = SQLGetDiagRecW (handleType, handle, errNum, sqlStateW, &nativeError, errMsgW, ERRMSG_LEN, &textLengthPtr);
  55. if (retcode == SQL_INVALID_HANDLE)
  56. {
  57. fprintf (stderr, "checkError function was called with an invalid handle!!\n");
  58. return 1;
  59. }
  60. if ((retcode == SQL_SUCCESS) || (retcode == SQL_SUCCESS_WITH_INFO))
  61. {
  62. sqlState = (SQLCHAR *) malloc (wcslen(sqlStateW) + sizeof(char))
  63. ;
  64. wcstombs( (char *) sqlState, sqlStateW, wcslen(sqlStateW)
  65. + sizeof(char));
  66. errMsg = (SQLCHAR *) malloc (wcslen(errMsgW) + sizeof(char));
  67. wcstombs( (char *) errMsg, errMsgW, wcslen(errMsgW)
  68. + sizeof(char));
  69. fprintf (stderr, "ERROR: %d: %s : %s \n", nativeError, sqlState , errMsg);
  70. }
  71. errNum++;
  72. }
  73. fprintf (stderr, "%s\n", errmsg);
  74. return 1; /* all errors on this handle have been reported */
  75. }
  76. else
  77. return 0; /* no errors to report */
  78. }
  79. int main (long argc,
  80. char* argv[])
  81. {
  82. /* Declare variables
  83. */
  84. /* Handles */
  85. SQLHDBC hdbc;
  86. SQLHENV henv;
  87. SQLHSTMT hstmt;
  88. /* Smart large object file descriptor */
  89. SQLINTEGER lofd;
  90. SQLLEN lofd_valsize = 0;
  91. /* Smart large object specification structure */
  92. SQLWCHAR* lospec_bufferW;
  93. SQLSMALLINT lospec_size;
  94. SQLLEN lospec_valsize = 0;
  95. /* Smart large object status structure */
  96. SQLWCHAR* lostat_bufferW;
  97. SQLSMALLINT lostat_size;
  98. SQLLEN lostat_valsize = 0;
  99. /* Smart large object pointer structure */
  100. SQLWCHAR* loptr_bufferW;
  101. SQLSMALLINT loptr_size;
  102. SQLLEN loptr_valsize = 0;
  103. /* Miscellaneous variables */
  104. SQLWCHAR *dsnW; /*name of the DSN used for connecting to the database*/
  105. SQLRETURN rc = 0;
  106. SQLINTEGER in;
  107. SQLWCHAR verInfoBufferW[BUFFER_LENW];
  108. SQLSMALLINT verInfoLen;
  109. SQLWCHAR* selectStmtW = (SQLWCHAR *) L"SELECT advert FROM item WHERE item_num = 1004";
  110. SQLINTEGER lo_size;
  111. SQLINTEGER mode = LO_RDONLY;
  112. SQLCHAR sbspace_name[BUFFER_LEN];
  113. SQLWCHAR sbspace_nameW[BUFFER_LENW];
  114. SQLINTEGER sbspace_name_size = SQL_NTS;
  115. SQLLEN cbMode = 0, cbLoSize = 0;
  116. int lenArgv1;
  117. /* STEP 1. Get data source name from command line (or use default)
  118. ** Allocate the environment handle and set ODBC version
  119. ** Allocate the connection handle
  120. ** Establish the database connection
  121. ** Get version information from the database server
  122. ** -- if version < 9.x (not UDO enabled), exit with error message
  123. ** Allocate the statement handle
  124. */
  125. if (argc != 2)
  126. {
  127. /* Use default dsnW - odbc_demo */
  128. fprintf (stdout, "\nUsing default DSN : %s\n", defDsn);
  129. dsnW = (SQLWCHAR *) malloc( wcslen(defDsnW) * sizeof(SQLWCHAR)
  130. + sizeof(SQLWCHAR) );
  131. wcscpy ((SQLWCHAR *)dsnW, (SQLWCHAR *)defDsnW);
  132. }
  133. else
  134. {
  135. /* Use specified dsnW */
  136. lenArgv1 = strlen((char *)argv[1]);
  137. dsnW = (SQLWCHAR *) malloc (lenArgv1 * sizeof(SQLWCHAR)
  138. + sizeof(SQLWCHAR));
  139. mbstowcs (dsnW, (char *)argv[1], lenArgv1 + sizeof(char));
  140. fprintf (stdout, "\nUsing specified DSN : %s\n", argv[1]);
  141. }
  142. /* Allocate the Environment handle */
  143. rc = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
  144. if (rc != SQL_SUCCESS)
  145. {
  146. fprintf (stdout, "Environment Handle Allocation failed\nExiting!!\n");
  147. return (1);
  148. }
  149. /* Set the ODBC version to 3.0 */
  150. rc = SQLSetEnvAttr (henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
  151. if (checkError (rc, SQL_HANDLE_ENV, henv, (SQLCHAR *) "Error in Step 1 -- SQLSetEnvAttr failed\nExiting!!\n"))
  152. return (1);
  153. /* Allocate the connection handle */
  154. rc = SQLAllocHandle (SQL_HANDLE_DBC, henv, &hdbc);
  155. if (checkError (rc, SQL_HANDLE_ENV, henv, (SQLCHAR *) "Error in Step 1 -- Connection Handle Allocation failed\nExiting!!\n"))
  156. return (1);
  157. /* Establish the database connection */
  158. rc = SQLConnectW (hdbc, dsnW, SQL_NTS, (SQLWCHAR *) L"", SQL_NTS, (SQLWCHAR *) L"", SQL_NTS);
  159. if (checkError (rc, SQL_HANDLE_DBC, hdbc, (SQLCHAR *) "Error in Step 1 -- SQLConnect failed\nExiting!!\n"))
  160. return (1);
  161. /* Get version information from the database server
  162. If version < 9.x (not UDO enabled), exit with error message */
  163. rc = SQLGetInfoW (hdbc, SQL_DBMS_VER, verInfoBufferW, BUFFER_LENW, &verInfoLen);
  164. if (checkError (rc, SQL_HANDLE_DBC, hdbc, (SQLCHAR *) "Error in Step 1 -- SQLGetInfo failed\n"))
  165. return 1;
  166. if ((wcsncmp ((SQLWCHAR *) verInfoBufferW, L"09", 2)) < 0)
  167. {
  168. fprintf (stdout, "\n** This test can only be run against UDO-enabled database server -- version 9 or higher **\n");
  169. return 1;
  170. }
  171. /* Allocate the statement handle */
  172. rc = SQLAllocHandle (SQL_HANDLE_STMT, hdbc, &hstmt );
  173. if (checkError (rc, SQL_HANDLE_DBC, hdbc, (SQLCHAR *) "Error in Step 1 -- Statement Handle Allocation failed\nExiting!!"))
  174. return (1);
  175. fprintf (stdout, "STEP 1 done...connected to database\n");
  176. /* STEP 2. Select a smart-large object from the database
  177. ** -- the select statement executed is -
  178. ** "SELECT advert FROM item WHERE item_num = 1004"
  179. */
  180. /* Execute the select statement */
  181. rc = SQLExecDirectW (hstmt, selectStmtW, SQL_NTS);
  182. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 2 -- SQLExecDirect failed\n"))
  183. goto Exit;
  184. fprintf (stdout, "STEP 2 done...select statement executed...smart large object retrieved from the databse\n");
  185. /* STEP 3. Get the size of the smart large object pointer structure
  186. ** Allocate a buffer to hold the structure.
  187. ** Get the smart large object pointer structure from the database
  188. ** Close the result set cursor
  189. */
  190. /* Get the size of the smart large object pointer structure */
  191. rc = SQLGetInfo (hdbc, SQL_INFX_LO_PTR_LENGTH, &loptr_size, sizeof(loptr_size), NULL);
  192. if (checkError (rc, SQL_HANDLE_DBC, hdbc, (SQLCHAR *) "Error in Step 3 -- SQLGetInfo failed\n"))
  193. goto Exit;
  194. /* Allocate a buffer to hold the smart large object pointer structure */
  195. loptr_bufferW = malloc (loptr_size);
  196. /* Bind the smart large object pointer structure buffer allocated to the column
  197. in the result set & fetch it from the database */
  198. rc = SQLBindCol (hstmt, 1, SQL_C_BINARY, loptr_bufferW, loptr_size, &loptr_valsize);
  199. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 3 -- SQLBindCol failed\n"))
  200. goto Exit;
  201. rc = SQLFetch (hstmt);
  202. if (rc == SQL_NO_DATA_FOUND)
  203. {
  204. fprintf (stdout, "No Data Found\nExiting!!\n");
  205. goto Exit;
  206. }
  207. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 3 -- SQLFetch failed\n"))
  208. goto Exit;
  209. /* Close the result set cursor */
  210. rc = SQLCloseCursor (hstmt);
  211. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 3 -- SQLCloseCursor failed\n"))
  212. goto Exit;
  213. fprintf (stdout, "STEP 3 done...smart large object pointer structure fetched from the database\n");
  214. /* STEP 4. Use the smart large object's pointer structure to open it and obtain the smart large
  215. ** object file descriptor.
  216. ** Reset the statement parameters
  217. */
  218. rc = SQLBindParameter (hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_LONG,
  219. SQL_INTEGER, (UDWORD)0, 0, &lofd, sizeof(lofd), &lofd_valsize);
  220. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 4 -- SQLBindParameter failed (param 1)\n"))
  221. goto Exit;
  222. rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY,
  223. SQL_INFX_UDT_FIXED, (UDWORD)loptr_size, 0, loptr_bufferW,
  224. loptr_size, &loptr_valsize);
  225. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 4 -- SQLBindParameter failed (param 2)\n"))
  226. goto Exit;
  227. rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_LONG,
  228. SQL_INTEGER, (UDWORD)0, 0, &mode, sizeof(mode), &cbMode);
  229. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 4 -- SQLBindParameter failed (param 3)\n"))
  230. goto Exit;
  231. rc = SQLExecDirectW (hstmt, (SQLWCHAR *) L"{? = call ifx_lo_open(?, ?)}", SQL_NTS);
  232. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 4 -- SQLExecDirect failed\n"))
  233. goto Exit;
  234. /* Reset the statement parameters */
  235. rc = SQLFreeStmt (hstmt, SQL_RESET_PARAMS);
  236. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 4 -- SQLFreeStmt failed\n"))
  237. goto Exit;
  238. fprintf (stdout, "STEP 4 done...smart large object opened... file descriptor obtained\n");
  239. /* STEP 5. Get the size of the smart large object status structure
  240. ** Allocate a buffer to hold the structure.
  241. ** Get the smart large object status structure from the database
  242. ** Reset the statement parameters
  243. */
  244. /* Get the size of the smart large object status structure */
  245. rc = SQLGetInfoW (hdbc, SQL_INFX_LO_STAT_LENGTH, &lostat_size,
  246. sizeof(lostat_size), NULL);
  247. if (checkError (rc, SQL_HANDLE_DBC, hdbc, (SQLCHAR *) "Error in Step 5 -- SQLGetInfo failed\n"))
  248. goto Exit;
  249. /* Allocate a buffer to hold the smart large object status structure. */
  250. lostat_bufferW = malloc(lostat_size);
  251. /* Get the smart large object status structure from the database. */
  252. rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG,
  253. SQL_INTEGER, (UDWORD)0, 0, &lofd, sizeof(lofd), &lofd_valsize);
  254. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 5 -- SQLBindParameter failed (param 1)\n"))
  255. goto Exit;
  256. rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT_OUTPUT,
  257. SQL_C_BINARY, SQL_INFX_UDT_FIXED, (UDWORD)lostat_size, 0,
  258. lostat_bufferW, lostat_size, &lostat_valsize);
  259. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 5 -- SQLBindParameter failed (param 2)\n"))
  260. goto Exit;
  261. rc = SQLExecDirectW (hstmt, (SQLWCHAR *) L"{call ifx_lo_stat(?, ?)}",
  262. SQL_NTS);
  263. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 5 -- SQLExecDirect failed\n"))
  264. goto Exit;
  265. /* Reset the statement parameters */
  266. rc = SQLFreeStmt (hstmt, SQL_RESET_PARAMS);
  267. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 5 -- SQLFreeStmt failed\n"))
  268. goto Exit;
  269. fprintf (stdout, "STEP 5 done...smart large object status structure fetched from the database\n");
  270. /* STEP 6. Use the smart large object's status structure to get the size
  271. ** of the smart large object
  272. ** Reset the statement parameters
  273. **
  274. ** You can use additional ifx_lo_stat_*() functions to get more
  275. ** status information about the samrt large object.
  276. **
  277. ** You can also use it to retrieve the smart large object specification
  278. ** structure and get further information about the smart large object
  279. ** using it's specification structure.
  280. */
  281. /* Use the smart large object status structure to get the size
  282. of the smart large object. */
  283. rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY,
  284. SQL_INFX_UDT_FIXED, (UDWORD)lostat_size, 0, lostat_bufferW,
  285. lostat_size, &lostat_valsize);
  286. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 6 -- SQLBindParameter failed (param 1)\n"))
  287. goto Exit;
  288. rc = SQLBindParameter (hstmt, 2, SQL_PARAM_OUTPUT, SQL_C_LONG,
  289. SQL_BIGINT, (UDWORD)0, 0, &lo_size, sizeof(lo_size), &cbLoSize);
  290. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 6 -- SQLBindParameter failed (param 1)\n"))
  291. goto Exit;
  292. rc = SQLExecDirectW (hstmt, (SQLWCHAR *) L"{call ifx_lo_stat_size(?, ?)}",
  293. SQL_NTS);
  294. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 6 -- SQLExecDirect failed\n"))
  295. goto Exit;
  296. /* Reset the statement parameters */
  297. rc = SQLFreeStmt (hstmt, SQL_RESET_PARAMS);
  298. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 6 -- SQLFreeStmt failed\n"))
  299. goto Exit;
  300. fprintf (stdout, "LARGE OBJECT SIZE = %ld\n", lo_size);
  301. fprintf (stdout, "STEP 6 done...smart large object size retrieved\n");
  302. /* STEP 7. Get the size of the smart large object specification structure
  303. ** Allocate a buffer to hold the structure.
  304. ** Get the smart large object specification structure from the database
  305. ** Reset the statement parameters
  306. */
  307. /* Get the size of the smart large object specification structure */
  308. rc = SQLGetInfoW(hdbc, SQL_INFX_LO_SPEC_LENGTH, &lospec_size,
  309. sizeof(lospec_size), NULL);
  310. if (checkError (rc, SQL_HANDLE_DBC, hdbc, (SQLCHAR *) "Error in Step 7 -- SQLGetInfo failed\n"))
  311. goto Exit;
  312. /* Allocate a buffer to hold the smart large object specification structure. */
  313. lospec_bufferW = malloc (lospec_size);
  314. /* Get the smart large object specification structure from the database */
  315. rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY,
  316. SQL_INFX_UDT_FIXED, (UDWORD)lostat_size, 0, lostat_bufferW,
  317. lostat_size, &lostat_valsize);
  318. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 7 -- SQLBindParameter failed (param 1)\n"))
  319. goto Exit;
  320. rc = SQLBindParameter (hstmt, 2, SQL_PARAM_OUTPUT, SQL_C_BINARY,
  321. SQL_INFX_UDT_FIXED, (UDWORD)lospec_size, 0, lospec_bufferW,
  322. lospec_size, &lospec_valsize);
  323. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 7 -- SQLBindParameter failed (param 2)\n"))
  324. goto Exit;
  325. rc = SQLExecDirectW (hstmt, (SQLWCHAR *) L"{call ifx_lo_stat_cspec(?, ?)}",
  326. SQL_NTS);
  327. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 7 -- SQLExecDirect failed\n"))
  328. goto Exit;
  329. fprintf (stdout, "STEP 7 done...smart large object status structure fetched from the database\n");
  330. /* STEP 8. Use the smart large object's specification structure to get the sbspace
  331. ** name where the smart large object is stored
  332. ** Reset the statement parameters
  333. */
  334. /* Use the smart large object's specification structure to get
  335. the sbspace name of the smart large object. */
  336. rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY,
  337. SQL_INFX_UDT_FIXED, (UDWORD)lospec_size, 0, lospec_bufferW,
  338. lospec_size, &lospec_valsize);
  339. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 8 -- SQLBindParameter failed (param 1)\n"))
  340. goto Exit;
  341. rc = SQLBindParameter (hstmt, 2, SQL_PARAM_OUTPUT, SQL_C_CHAR,
  342. SQL_CHAR, BUFFER_LEN, 0, sbspace_name, BUFFER_LEN,
  343. &sbspace_name_size);
  344. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 8 -- SQLBindParameter failed (param 2)\n"))
  345. goto Exit;
  346. rc = SQLExecDirectW (hstmt, (SQLWCHAR *) L"{call ifx_lo_specget_sbspace(?, ?)}", SQL_NTS);
  347. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 8 -- SQLExecDirect failed\n"))
  348. goto Exit;
  349. /*
  350. sbspace_name = (SQLCHAR *) malloc (wcslen(sbspace_nameW)
  351. + sizeof(char));
  352. wcstombs( (char *) sbspace_name, sbspace_nameW, wcslen(sbspace_nameW)
  353. + sizeof(char));
  354. */
  355. fprintf (stdout, "LARGE OBJECT SBSPACE NAME = %s\n", sbspace_name);
  356. fprintf (stdout, "STEP 8 done...large object sbspace name retrieved\n");
  357. /* STEP 9. Close the smart large object.
  358. */
  359. rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG,
  360. SQL_INTEGER, (UDWORD)0, 0, &lofd, sizeof(lofd), &lofd_valsize);
  361. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 9 -- SQLBindParameter failed\n"))
  362. goto Exit;
  363. rc = SQLExecDirectW (hstmt, (SQLWCHAR *) L"{call ifx_lo_close(?)}", SQL_NTS);
  364. if (checkError (rc, SQL_HANDLE_STMT, hstmt, (SQLCHAR *) "Error in Step 9 -- SQLExecDirect failed\n"))
  365. goto Exit;
  366. fprintf (stdout, "STEP 9 done...smart large object closed\n");
  367. /* STEP 10. Free the allocated buffers */
  368. free (loptr_bufferW);
  369. free (lostat_bufferW);
  370. free (lospec_bufferW);
  371. fprintf (stdout, "STEP 10 done...smart large object buffers freed\n");
  372. Exit:
  373. /* CLEANUP: Close the statement handle
  374. ** Free the statement handle
  375. ** Disconnect from the datasource
  376. ** Free the connection and environment handles
  377. ** Exit
  378. */
  379. /* Close the statement handle */
  380. SQLFreeStmt (hstmt, SQL_CLOSE);
  381. /* Free the statement handle */
  382. SQLFreeHandle (SQL_HANDLE_STMT, hstmt);
  383. /* Disconnect from the data source */
  384. SQLDisconnect (hdbc);
  385. /* Free the environment handle and the database connection handle */
  386. SQLFreeHandle (SQL_HANDLE_DBC, hdbc);
  387. SQLFreeHandle (SQL_HANDLE_ENV, henv);
  388. fprintf (stdout,"\n\nHit <Enter> to terminate the program...\n\n");
  389. in = getchar ();
  390. return (rc);
  391. }