home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / database / sybase / 550 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.9 KB  |  110 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!darwin.sura.net!haven.umd.edu!news.umbc.edu!gmuvax2!3583aj
  3. From: 3583aj@gmuvax2.gmu.edu (Akhil)
  4. Subject: Problem using cursors in Sybase Db library
  5. Message-ID: <1992Dec22.175437.28110@gmuvax2.gmu.edu>
  6. Keywords: Cursors, Db Library
  7. Organization: George Mason University, Fairfax, Virginia, USA 
  8. Date: Tue, 22 Dec 1992 17:54:37 GMT
  9. Lines: 99
  10.  
  11.  
  12. I am using DB-Library ver 4.2 for DOS to develop client applications and Sybase SQL server ver 4.2 for Novell LAN as the database server.
  13. The PC clients are connected to the server using Novell ver 3.11
  14.  
  15. I am trying to use the cursor APIs .
  16.  
  17. The dbcursoropen API does not work with keyset cursors.
  18. When this function is executed the program just exits. Inspite of having
  19. installed an error handler, no error messages are displayed. The API
  20. works fine for dynamic and static cursors. It also does not work for
  21. mixed cursors (i.e. keyset + dynamic)
  22.  
  23. #define DBMSDOS
  24. #include <sqlfront.h>
  25. #include <sqldb.h>
  26. #include <stdio.h>
  27.  
  28. int err_handler();
  29. int msg_handler();
  30.  
  31. #define NROWS 5
  32. #define KEYSET CUR_KEYSET /* program works if KEYSET is CUR_DYNAMIC */ 
  33. #define CONCUROPT CUR_OPTCC
  34.  
  35. char stmt[] = "select au_lname, au_fname from authors where contract = 1";
  36.  
  37. DBINT pstat[NROWS];
  38. char au_lname[NROWS][4];
  39. char au_fname[NROWS][21];
  40. DBINT au_fnamelen[NROWS];
  41. char *stats[NROWS];
  42. char values[250];
  43.  
  44. main()
  45. {
  46.     DBPROCESS *dbproc;
  47.     LOGINREC *login;
  48.     int i;
  49.     DBCURSOR *hcursor;
  50.  
  51.     /*dbinit();*/
  52.     printf("after dbinit\n");
  53.     dberrhandle(err_handler);
  54.     dbmsghandle(msg_handler);
  55.     login = dblogin();
  56.     DBSETLUSER(login, "sa");
  57.     DBSETLPWD(login, "");
  58.  
  59.  
  60.     dbproc = dbopen(login, (char *)NULL);
  61.     dbuse(dbproc, "pubs");
  62.  
  63.     /* The program exits after executing the following function if
  64. KEYSET is CUR_KEYSET */
  65.  
  66.     hcursor = dbcursoropen(dbproc, stmt, KEYSET, CONCUROPT, NROWS, pstat);
  67.     printf("after dbcursoropen\n");
  68.     dbcursorbind(hcursor, 1, NTBSTRINGBIND, 41, NULL, (char *)au_lname); 
  69.     dbcursorbind(hcursor, 2, NTBSTRINGBIND, 21, au_fnamelen, (char *)au_fname);
  70.     dbcursorfetch(hcursor, FETCH_FIRST, 0);
  71.     for (i = 0; i < NROWS; i++)
  72.     printf("Name :%s %s\n", au_fname[i], au_lname[i]);
  73.  
  74. }
  75.  
  76. int err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr)
  77. DBPROCESS    *dbproc;
  78. int    severity;
  79. int    dberr;
  80. int    oserr;
  81. char    *dberrstr;
  82. char    *oserrstr;
  83. {
  84.     if ((dbproc == NULL) || (DBDEAD(dbproc)))
  85.         return(INT_EXIT);
  86.     else
  87.     {
  88.         printf("DB-LIBRARY error:\n\t%s\n", dberrstr);
  89.  
  90.         if (oserr != DBNOERR)
  91.             printf("Operating-system error:\n\t%s\n", oserrstr);
  92.  
  93.         return(INT_CANCEL);
  94.     }
  95. }
  96.  
  97. int msg_handler(dbproc, msgno, msgstate, severity, msgtext)
  98. DBPROCESS    *dbproc;
  99. DBINT    msgno;
  100. int    msgstate;
  101. int    severity;
  102. char    *msgtext;
  103. {
  104.     printf
  105.     ("SQL Server message %ld, state %d, severity %d:\n\t%s\n",
  106.     msgno, msgstate, severity, msgtext);
  107.     return(0);
  108. }
  109.  
  110.