Mail Archives: cygwin/2001/08/06/15:49:36
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: text/plain;
charset="iso-8859-1"
>-----Original Message-----
>From: Tim Heath [mailto:th374862 AT cosd DOT fedex DOT com]
>Sent: Monday, August 06, 2001 7:04 PM
>To: CLYNES Darius (SCIC)
>Subject: Re: Oracle client in Cygwin?
>
>
>I would really like an example using pro-c if that is ok :)
Ok Attached is:
a makefile,
a settings file (defs.mk), and a dos2unix converter - both used by the
makefile.
a main.c
and an example.pc
just fill in the username, password, database
and change the select statement to correspond to your
data. good luck
>
>Thanks,
>
>Tim Heath
>
>Darius DOT Clynes AT cec DOT eu DOT int wrote:
>>
>> Jim
>>
>> I know of 3 ways to do this.
>>
>> 1) Pro*C (the way I do it and you link to SQLLIB18.lib)
>> you have to call the pro-c compiler first
>>
>> 2) OCI (haven't tried this from cygwin but it should work
>if you link with
>> the right libs)
>>
>> 3) ODBC (haven't tried this from cygwin, but if you do let
>me know if it
>> works,
>> and send me an example please)
>>
>> After you install the Oracle Client, (with pro*c) and if you
>need an example
>>
>> i would be happy to send you one.
>>
>> Darius
>>
>> Darius Clynes
>> Software Engineer
>> European Commission
>> Rue De Mot 24
>> Brussels, 1040
>> Belgium
>>
>> Office tel: +32 2 2962441
>> fax: +32 2 2966025
>> Cell phone: +32 476 218850
>>
>> >-----Original Message-----
>> >From: Jim Drash [mailto:jdrash AT eesus DOT jnj DOT com]
>> >Sent: Monday, August 06, 2001 6:49 PM
>> >To: cygwin AT cygwin DOT com
>> >Subject: Oracle client in Cygwin?
>> >
>> >
>> >Is it possible to atttache to Oracle databases from within Cygwin?
>> >If so what is required? If this has been asked before, I could not
>> >find any reference to it in the archives?
>> >
>> >thanks in advance,
>> >jim drash <jdrash AT eesus DOT jnj DOT com>
>> >
>> >--
>> >Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
>> >Bug reporting: http://cygwin.com/bugs.html
>> >Documentation: http://cygwin.com/docs.html
>> >FAQ: http://cygwin.com/faq/
>> >
>>
>> --
>> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
>> Bug reporting: http://cygwin.com/bugs.html
>> Documentation: http://cygwin.com/docs.html
>> FAQ: http://cygwin.com/faq/
>
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: application/octet-stream;
name="example.pc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="example.pc"
=0A=
#include <stdio.h>=0A=
#include <string.h>=0A=
#include <stdlib.h>=0A=
#include <sqlda.h>=0A=
=0A=
=0A=
/* Include the SQL Communications Area.=0A=
You can use #include or EXEC SQL INCLUDE. */=0A=
#include <sqlca.h>=0A=
=0A=
/* Declare error handling function. */=0A=
void sql_error(msg)=0A=
char *msg;=0A=
{=0A=
char err_msg[128];=0A=
size_t buf_len, msg_len;=0A=
=0A=
EXEC SQL WHENEVER SQLERROR CONTINUE;=0A=
=0A=
printf("\n%s\n", msg);=0A=
buf_len =3D sizeof (err_msg);=0A=
sqlglm(err_msg, &buf_len, &msg_len);=0A=
printf("%.*s\n", msg_len, err_msg);=0A=
=0A=
EXEC SQL ROLLBACK RELEASE;=0A=
exit(EXIT_FAILURE);=0A=
}=0A=
=0A=
void example_proc()=0A=
{=0A=
=0A=
EXEC SQL BEGIN DECLARE SECTION;=0A=
=0A=
varchar username[80]; =0A=
varchar the_nomacc[20]; =0A=
varchar temp[20]; =0A=
=0A=
EXEC SQL END DECLARE SECTION;=0A=
=0A=
/* Include the SQL Communications Area.=0A=
You can use #include or EXEC SQL INCLUDE. */=0A=
#include <sqlca.h>=0A=
=0A=
=0A=
/* Connect to ORACLE--=0A=
* Copy the username into the VARCHAR.=0A=
*/=0A=
strcpy((char *) username.arr, =
"oracleusername/password AT database");=0A=
=0A=
/* Set the length component of the VARCHAR. */=0A=
username.len =3D =0A=
(unsigned short) strlen((char *) username.arr);=0A=
=0A=
=0A=
/* Register sql_error() as the error handler. */=0A=
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");=0A=
=0A=
/* Connect to ORACLE. Program will call sql_error()=0A=
* if an error occurs when connecting to the database.=0A=
*/=0A=
=0A=
EXEC SQL CONNECT :username;=0A=
=0A=
printf("\nConnected to ORACLE as user: %s\n", username.arr);=0A=
=0A=
=0A=
=0A=
EXEC SQL SELECT to_char(sysdate,'DD-MON-YYYY') into :temp=0A=
from dual;=0A=
=0A=
=0A=
temp.arr[temp.len] =3D '\0';=0A=
=0A=
printf("ORACLE date is:%s\n", temp.arr);=0A=
=0A=
/* Branch to the notfound label when the=0A=
* 1403 ("No data found") condition occurs.=0A=
*/=0A=
EXEC SQL WHENEVER NOT FOUND GOTO notfound;=0A=
=0A=
=0A=
=0A=
EXEC SQL SELECT nomacc =0A=
INTO :the_nomacc=0A=
FROM INTERPRETE =0A=
WHERE matricule =3D 510022;=0A=
=0A=
=0A=
/* Null-terminate the output string data. */=0A=
the_nomacc.arr[the_nomacc.len] =3D '\0';=0A=
printf("%s\n",=0A=
the_nomacc.arr);=0A=
=0A=
EXEC SQL ROLLBACK WORK RELEASE;=0A=
=0A=
return;=0A=
=0A=
notfound:=0A=
printf("\nNomacc not found - try again.\n");=0A=
=0A=
=0A=
=0A=
/* Disconnect from ORACLE. */=0A=
EXEC SQL ROLLBACK WORK RELEASE;=0A=
=0A=
/*=0A=
exit(EXIT_SUCCESS);=0A=
*/=0A=
}=0A=
=0A=
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: application/octet-stream;
name="Makefile"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Makefile"
include defs.mk=0A=
#=0A=
# makefile for vuit generated applications.=0A=
#=0A=
=0A=
#=0A=
# Need extra suffixes for uid file compilation.=0A=
#=0A=
.SUFFIXES: .pc=0A=
=0A=
CINCLUDES =3D -I. -I$(PCCINCLUDE) =0A=
LOCALCFLAGS =3D -g $(CINCLUDES) =0A=
=0A=
LINTFLAGS=3D $(CINCLUDES)=0A=
=0A=
=0A=
LIBS =3D =0A=
=0A=
SRCS =3D main.c=0A=
=0A=
SRCPCS =3D example.pc =0A=
=0A=
OBJS =3D main.o example.o =0A=
=0A=
IMAGE =3D my_example =0A=
=0A=
=
=0A=
all : $(IMAGE) =0A=
=0A=
=0A=
$(IMAGE) : $(OBJS) =0A=
$(CC) -o $(IMAGE) $(OBJS) $(LDFLAGS) $(LIBS) $(ORALIBS) =0A=
echo =07=07=07=0A=
=0A=
main.o: main.c =0A=
=0A=
example.o: example.pc example.c =0A=
=0A=
=0A=
#.DEFAULT:=0A=
# co $<=0A=
=0A=
clean:=0A=
rm -f *.o $(IMAGE) $(SRCPCS:.pc=3D.c)=0A=
=0A=
=0A=
=0A=
# DO NOT DELETE THIS LINE -- make depend depends on it.=0A=
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: application/octet-stream;
name="main.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="main.c"
main()=0A=
{=0A=
example_proc();=0A=
}=0A=
=0A=
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: application/octet-stream;
name="dos2unix"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="dos2unix"
chmod +rw $1 =0A=
cat $1 | tr -d '\r' > /tmp/$1 =0A=
cat /tmp/$1 > $1=0A=
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: application/octet-stream;
name="defs.mk"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="defs.mk"
# default.alpha.mk=0A=
=0A=
.SUFFIXES: .gen .mth .cxpc .cxx .pc .o .h .c=0A=
=0A=
_V6COMP=3DDBMS=3DV6=0A=
=0A=
=0A=
CC =3D cc $(X_LIB_INCLUDES) -D_SUNCC=0A=
CXX =3D cxx -fno-strict-prototype $(X_LIB_INCLUDES) -D_SUNCC=0A=
=0A=
OPTIM =3D -O -Olimit 2000=0A=
DEBUG =3D -g=0A=
=0A=
CFLAGS =3D $(DEBUG)=0A=
LOCALCFLAGS=3D=0A=
CXXFLAGS =3D $(DEBUG)=0A=
LOCALCXXFLAGS=3D=0A=
=0A=
ORACLE_HOME=3DC:/Program\ Files/Oracle=0A=
PROC=3D$(ORACLE_HOME)/bin/proc=0A=
PCCINCLUDE=3D$(ORACLE_HOME)/PRO22/C/INCLUDE=0A=
SQLCHECK=3Dsqlcheck=3Dfull userid=3Dchelia/florent1 AT test=0A=
PROCFLAGS=3Direclen=3D1024 oreclen=3D1024 ltype=3Dnone =
select_error=3Dno $(SQLCHECK) $(_V6COMP) MAXOPENCURSORS=3D255=0A=
PROCXXFLAGS=3Direclen=3D1024 oreclen=3D1024 ltype=3Dnone =
select_error=3Dno $(SQLCHECK) $(_V6COMP) MAXOPENCURSORS=3D255 =
code=3Dcpp=0A=
=0A=
LOCALPROCFLAGS=3Dinclude=3D. include=3D$(PCCINCLUDE) =
include=3DC:\\cygwin\\EXTRAS\\develop=0A=
=0A=
ORA_LIB_DIR=3D$(ORACLE_HOME)/PRO22/C/INCLUDE=0A=
ORALIBS=3D$(ORACLE_HOME)/PRO22/LIB/MSVC/SQLLIB18.LIB=0A=
=0A=
=0A=
=0A=
=0A=
=0A=
=0A=
.cxpc.o :=0A=
rm -f $(<:.cxpc=3D.cxx)=0A=
( ORACLE_HOME=3D$(ORACLE_HOME); export ORACLE_HOME; $(PROC) =
$(PROCXXFLAGS) $(LOCALPROCFLAGS) iname=3D$< oname=3D$(<:.cxpc=3D.cxx) =
)=0A=
rm -f $(<:.cxpc=3D.lis)=0A=
dos2unix $(<:.cxpc=3D.cxx)=0A=
chmod a-w $(<:.cxpc=3D.cxx)=0A=
$(CXX) -c $(CXXFLAGS) $(LOCALCXXFLAGS) -I$(PCCINCLUDE) =
$(<:.cxpc=3D.cxx)=0A=
# rm -f $(<:.cxpc=3D.cxx)=0A=
=0A=
.pc.o :=0A=
rm -f $(<:.pc=3D.c)=0A=
( ORACLE_HOME=3D$(ORACLE_HOME); export ORACLE_HOME; $(PROC) =
$(PROCFLAGS) $(LOCALPROCFLAGS) iname=3D$< oname=3D$(<:.pc=3D.c) )=0A=
rm -f $(<:.pc=3D.lis)=0A=
dos2unix $(<:.pc=3D.c)=0A=
chmod a-w $(<:.pc=3D.c)=0A=
$(CC) -c $(CFLAGS) $(LOCALCFLAGS) -I$(PCCINCLUDE) $(<:.pc=3D.c)=0A=
# rm -f $(<:.pc=3D.c)=0A=
=0A=
.cxx.o :=0A=
$(CXX) -c $(CXXFLAGS) $(LOCALCXXFLAGS) $<=0A=
=0A=
.c.o :=0A=
$(CC) -c $(CFLAGS) $(LOCALCFLAGS) $<=0A=
=0A=
.pc.c : =0A=
rm -f $(<:.pc=3D.c)=0A=
( ORACLE_HOME=3D$(ORACLE_HOME); export ORACLE_HOME; $(PROC) =
$(PROCFLAGS) $(LOCALPROCFLAGS) iname=3D$< oname=3D$(<:.pc=3D.c) )=0A=
rm -f $(<:.pc=3D.lis)=0A=
dos2unix $(<:.pc=3D.c)=0A=
chmod a-w $(<:.pc=3D.c)=0A=
# $(PROC) $(PROCFLAGS) $(LOCALPROCFLAGS) iname=3D$< =
oname=3D$(<:.pc=3D.c)=0A=
=0A=
=0A=
=0A=
------_=_NextPart_000_01C11EAF.F83E5830
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------_=_NextPart_000_01C11EAF.F83E5830--
- Raw text -