Skip to content

Add more C examples and update the makefile and README files #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions C/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Oracle Call Interface (OCI) Examples
This directory contains samples that uses Oracle Call Interface's C libraries for accessing and working with Oracle Database.
It also contains a sample makefile that can be used to compile these samples and create executables.

List of files
-------------
| File Name | Description |
|-----------|-------------|
|[simpleConnDemo.c](./simpleConnDemo.c)| Shows a simple connection and query to Oracle Database using OCI. For explanation and the required setup, see the [blog](https://medium.com/oracledevs/oracle-call-interface-for-c-developers-simple-database-connection-and-query-58be8243a393).|
|[sessionPoolingDemo.c](./sessionPoolingDemo.c)| Shows session pooling with Oracle Database using OCI Threads. For explanation and the required setup, see the [blog](https://medium.com/oracledevs/oracle-call-interface-for-c-developers-session-pooling-and-multithreading-87f56cec993a).|
|[drcpDemo.c](./drcpDemo.c)| Shows a simple query with DRCP connection to Oracle Database using OCI|
8 changes: 4 additions & 4 deletions C/drcp.c → C/drcpDemo.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2022, Oracle. All rights reserved. */
/* Copyright (c) 2022, 2025, Oracle. All rights reserved. */

/* drcp.c */
/* drcpDemo.c */

/* Oracle OCI Database Resident Connection Pooling (DRCP) Example */
/* Christopher Jones, 2022 */
Expand All @@ -11,8 +11,8 @@
#include <unistd.h>
#include <oci.h>

// const OraText userName[] = "SCOTT";
// const OraText userPassword[] = "TIGER";
// const OraText userName[] = "<username>";
// const OraText userPassword[] = "<password>";

/* Take the user credentials as inputs*/
OraText userName[129];
Expand Down
25 changes: 17 additions & 8 deletions C/makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# Copyright (c) 2022, Oracle. All rights reserved.
# Makefile for Oracle OCI Database Resident Connection Pooling (DRCP) Example
# Copyright (c) 2022, 2025, Oracle. All rights reserved.
# Makefile for Oracle Call Interface examples
# Christopher Jones, 2022
# Sharad Chandran R, 2025

IC=$(HOME)/instantclient_19_11
# Update the instant client path here
IC=$(HOME)/instantclient_19_26
OLIB=$(IC)
OINC=$(IC)/sdk/include
DEMOS=drcpDemo simpleConnDemo sessionPoolingDemo

#OH=/u01/app/oracle/product/12.1.0/dbhome_1
# Uncomment the following 3 lines if you are using an
# Oracle Database home
#OH=/u01/app/oracle/product/19.26.0/dbhome_1
#OLIB=$(OH)/lib
#OINC=$(OH)/rdbms/public

drcp: clean
$(CC) -Wall -Wextra -c -I$(OINC) drcp.c
$(CC) -o drcp drcp.o -Wl,--rpath -Wl,$(OLIB) -L$(OLIB) -lclntsh
.PHONY: all clean

all: $(DEMOS)

$(DEMOS): %: %.c
$(CC) -Wall -Wextra -c -I$(OINC) $<
$(CC) -o $@ $@.o -Wl,--rpath -Wl,$(OLIB) -L$(OLIB) -lclntsh

clean:
rm -f drcp.o drcp
rm -f $(DEMOS) *.o
Loading