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:
- Write our C code with the include directives found in the
example.
- Do add csc_sybase prior to execution.
- 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):
- Example 1: Fixed
SQL query (Type class_ex1 to run this example
code.)
- Example 2: Simple
SQL query constructed on the fly (Type class_ex2
to run this example code.)
- Example 3: Use of
dbprhead and dbprrow (Type class_ex3 to run this
example code.)
- Example 4:
Binding to an integer (Type class_ex4 to run this
example code.)
- Example Makefile for
the above (use as make class_ex1, etc. in your
directory)