home *** CD-ROM | disk | FTP | other *** search
/ distrib.akp.su/Programming/Vb-6+Rus/ / distrib.akp.su.tar / distrib.akp.su / Programming / Vb-6+Rus / COMMON / MSDEV98 / BIN / IDE / XPWIZ.AWX / TEMPLATE / PROC.CPP < prev    next >
C/C++ Source or Header  |  1998-06-18  |  2KB  |  85 lines

  1. #include <stdafx.h>
  2.  
  3. #define XP_NOERROR              0
  4. #define XP_ERROR                1
  5. #define MAXCOLNAME                25
  6. #define MAXNAME                    25
  7. #define MAXTEXT                    255
  8.  
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. RETCODE __declspec(dllexport) $$XP_NAME$$(SRV_PROC *srvproc);
  14.  
  15. #ifdef __cplusplus
  16. }
  17. #endif
  18.  
  19. RETCODE __declspec(dllexport) $$XP_NAME$$(SRV_PROC *srvproc)
  20. {
  21.  
  22.     DBSMALLINT i = 0;
  23.     DBCHAR colname[MAXCOLNAME];
  24.     DBCHAR spName[MAXNAME];
  25.     DBCHAR spText[MAXTEXT];
  26.  
  27.     // Name of this procedure
  28.     wsprintf(spName, "$$XP_NAME$$");
  29.  
  30.  
  31.     //Send a text message
  32.     wsprintf(spText, "%s Sample Extended Stored Procedure", spName);
  33.     srv_sendmsg(
  34.         srvproc,
  35.         SRV_MSG_INFO,
  36.         0,
  37.         (DBTINYINT)0,
  38.         (DBTINYINT)0,
  39.         NULL,
  40.         0,
  41.         0,
  42.         spText,
  43.         SRV_NULLTERM);
  44.  
  45.  
  46.     //Set up the column names
  47.     wsprintf(colname, "ID");
  48.     srv_describe(srvproc, 1, colname, SRV_NULLTERM, SRVINT2, sizeof(DBSMALLINT), SRVINT2, sizeof(DBSMALLINT), 0);
  49.  
  50.     wsprintf(colname, "spName");
  51.     srv_describe(srvproc, 2, colname, SRV_NULLTERM, SRVCHAR, MAXNAME, SRVCHAR, 0, NULL);
  52.  
  53.     wsprintf(colname, "Text");
  54.     srv_describe(srvproc, 3, colname, SRV_NULLTERM, SRVCHAR, MAXTEXT, SRVCHAR, 0, NULL);
  55.  
  56.  
  57.     // Update field 2 "spName", same value for all rows
  58.     srv_setcoldata(srvproc, 2, spName);
  59.     srv_setcollen(srvproc, 2, strlen(spName));
  60.  
  61.  
  62.     // Send multiple rows of data
  63.     for (i = 0; i < 3; i++) {
  64.  
  65.         // Update field 1 "ID"
  66.         srv_setcoldata(srvproc, 1, &i);
  67.  
  68.         // Update field 3 "Text"
  69.         wsprintf(spText, "%d) Sample rowset generated by the %s extended stored procedure", i, spName);
  70.  
  71.         srv_setcoldata(srvproc, 3, spText);
  72.         srv_setcollen(srvproc, 3, strlen(spText));
  73.  
  74.         // Send the entire row
  75.         srv_sendrow(srvproc);
  76.     }
  77.  
  78.   
  79.     // Now return the number of rows processed
  80.     srv_senddone(srvproc, SRV_DONE_MORE | SRV_DONE_COUNT, (DBUSMALLINT)0, (DBINT)i);
  81.  
  82.     return XP_NOERROR ;
  83. }
  84.  
  85.