Running Sql in C

The C programs for Sql have the regular C format. The variable declarations and procedures are the same. The Sql calls are made by logging to the sybase server with a username and the password. The structures that enable the connection between your application code and the sybase server are LOGINREC, DBINT and DBPROCESS.

Steps for Running Sql in C:

  1. Write our C code with the include directives found in the example.
  2. Do add csc_sybase prior to execution.
  3. Compile your code with the flags
    -L/ncsu/csc_sybase/lib -lsybdb -lnsl -I/ncsu/csc_sybase/include -I/usr/athena/include
    Or, better yet, follow the example Makefile given below.
The files (the .c files were handed out in class):
  1. Example 1: Fixed SQL query (Type class_ex1 to run this example code.)
  2. Example 2: Simple SQL query constructed on the fly (Type class_ex2 to run this example code.)
  3. Example 3: Use of dbprhead and dbprrow (Type class_ex3 to run this example code.)
  4. Example 4: Binding to an integer (Type class_ex4 to run this example code.)
  5. Example Makefile for the above (use as make class_ex1, etc. in your directory)