home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- 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
- From: 3583aj@gmuvax2.gmu.edu (Akhil)
- Subject: Problem using cursors in Sybase Db library
- Message-ID: <1992Dec22.175437.28110@gmuvax2.gmu.edu>
- Keywords: Cursors, Db Library
- Organization: George Mason University, Fairfax, Virginia, USA
- Date: Tue, 22 Dec 1992 17:54:37 GMT
- Lines: 99
-
-
- 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.
- The PC clients are connected to the server using Novell ver 3.11
-
- I am trying to use the cursor APIs .
-
- The dbcursoropen API does not work with keyset cursors.
- When this function is executed the program just exits. Inspite of having
- installed an error handler, no error messages are displayed. The API
- works fine for dynamic and static cursors. It also does not work for
- mixed cursors (i.e. keyset + dynamic)
-
- #define DBMSDOS
- #include <sqlfront.h>
- #include <sqldb.h>
- #include <stdio.h>
-
- int err_handler();
- int msg_handler();
-
- #define NROWS 5
- #define KEYSET CUR_KEYSET /* program works if KEYSET is CUR_DYNAMIC */
- #define CONCUROPT CUR_OPTCC
-
- char stmt[] = "select au_lname, au_fname from authors where contract = 1";
-
- DBINT pstat[NROWS];
- char au_lname[NROWS][4];
- char au_fname[NROWS][21];
- DBINT au_fnamelen[NROWS];
- char *stats[NROWS];
- char values[250];
-
- main()
- {
- DBPROCESS *dbproc;
- LOGINREC *login;
- int i;
- DBCURSOR *hcursor;
-
- /*dbinit();*/
- printf("after dbinit\n");
- dberrhandle(err_handler);
- dbmsghandle(msg_handler);
- login = dblogin();
- DBSETLUSER(login, "sa");
- DBSETLPWD(login, "");
-
-
- dbproc = dbopen(login, (char *)NULL);
- dbuse(dbproc, "pubs");
-
- /* The program exits after executing the following function if
- KEYSET is CUR_KEYSET */
-
- hcursor = dbcursoropen(dbproc, stmt, KEYSET, CONCUROPT, NROWS, pstat);
- printf("after dbcursoropen\n");
- dbcursorbind(hcursor, 1, NTBSTRINGBIND, 41, NULL, (char *)au_lname);
- dbcursorbind(hcursor, 2, NTBSTRINGBIND, 21, au_fnamelen, (char *)au_fname);
- dbcursorfetch(hcursor, FETCH_FIRST, 0);
- for (i = 0; i < NROWS; i++)
- printf("Name :%s %s\n", au_fname[i], au_lname[i]);
-
- }
-
- int err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr)
- DBPROCESS *dbproc;
- int severity;
- int dberr;
- int oserr;
- char *dberrstr;
- char *oserrstr;
- {
- if ((dbproc == NULL) || (DBDEAD(dbproc)))
- return(INT_EXIT);
- else
- {
- printf("DB-LIBRARY error:\n\t%s\n", dberrstr);
-
- if (oserr != DBNOERR)
- printf("Operating-system error:\n\t%s\n", oserrstr);
-
- return(INT_CANCEL);
- }
- }
-
- int msg_handler(dbproc, msgno, msgstate, severity, msgtext)
- DBPROCESS *dbproc;
- DBINT msgno;
- int msgstate;
- int severity;
- char *msgtext;
- {
- printf
- ("SQL Server message %ld, state %d, severity %d:\n\t%s\n",
- msgno, msgstate, severity, msgtext);
- return(0);
- }
-
-