Tech Rocks

Coldfusion
Java
JQuery

An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Friday, January 23, 2009

Compiling Pro*C with Borland C (Bcc32) Compiler and Oracle

References
http://www.codepedia.com/1/CppBuilderLinkingErrors&SrcRev=8&DstRev=0&action=diff
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
http://srikanthtechnologies.com/articles/oracle/proc/dmlcom.html
http://www.orafaq.com/wiki/Pro*C
http://www.orafaq.com/forum/t/93439/0/
http://www.cprogramming.com/borland.html
http://www.acs.ilstu.edu/docs/Oracle/win.101/a96111/use.htm
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a97269/toc.htm
http://www.uaex.edu/srea/osee/52505.htm
http://bioinfo.uh.edu/cosc3480/ProC/ProC.htm
http://infolab.stanford.edu/~ullman/fcdb/oracle/or-proc.html
https://db.bme.hu/Manuals/Oracle/Oracle9/win.920/a96111/intro.htm


Installing Pro*C
Install freecommandlinetools.exe FREE Borland C compiler.

bcc32.cfg
-I"c:\Borland\bcc55\Include"
-L"c:\Borland\bcc55\Lib"
-L$(ORACLE_HOME)/lib -L$(ORACLE_HOME)/rdbms/lib

ilink32.cfg
-L"c:\Borland\bcc55\Lib";
-L"e:\oracle\product\10.2.0\db_1\precomp\lib";

Add the above files in the bin folder
C:\Borland\bcc55\Bin

Copy E:\oracle\product\10.2.0\db_1\precomp\LIB\orasql10.lib to C:\Borland\bcc55\Bin
Folder
Run coff2omf orasql10.lib orasql10~.lib
In bin folder
Copy orasql10~.lib to E:\oracle\product\10.2.0\db_1\precomp\LIB

Copy all lib files of oracle to C:\Borland\bcc55\Lib folder
Copy all .h files in E:\oracle\product\10.2.0\db_1\precomp\public to C:\Borland\bcc55\Include

Restart cmd prompt
Create db.h
#ifndef __BIT_TYPES_DEFINED__
#define __BIT_TYPES_DEFINED__
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
typedef unsigned __int64 u_int64_t;

#if defined __GNUC__
#include
#else
typedef short int16_t;
typedef int int32_t;
typedef __int64 int64_t;
#endif
#endif


#if !defined __GNUC__
typedef u_int64_t uintmax_t;
#ifdef _WIN64
typedef u_int64_t uintptr_t;
#else
typedef u_int32_t uintptr_t;
#endif
#endif

In C:\Borland\bcc55\Include

Now we are all set
Copy fun1.pc to bin folder C:\Borland\bcc55\Bin
#include
#include
#include
#include


EXEC SQL BEGIN DECLARE SECTION;
VARCHAR uid[30];
VARCHAR pwd[30];
VARCHAR db[30];
EXEC SQL END DECLARE SECTION;

EXEC SQL INCLUDE SQLCA.H;

void main()
{

strcpy(uid.arr,"system");
uid.len =strlen(uid.arr);
strcpy(pwd.arr,"abcd");
pwd.len = strlen(pwd.arr);
strcpy(db.arr,"hostname_for localhost");
db.len = strlen(db.arr);

EXEC SQL WHENEVER SQLERROR GOTO errexit;
EXEC SQL CONNECT :uid IDENTIFIED BY :pwd using :db;

if (sqlca.sqlcode == 0)
printf("Connected to Oracle\n");

EXEC SQL COMMIT WORK RELEASE;
return;

errexit:
printf("Connection failed");
return;


} /* end of main */
Run Proc fun1.pc
Run bcc32 /IC:E:\oracle\product\10.2.0\db_1\precomp\public fun1.c /LINK E:\oracle\product\10.2.0\db_1\precomp\LIB\orasql10~.lib
Run fun1
Enjoy!

0 comments :