Path: utzoo!attcan!uunet!ogicse!mintaka!mit-eddie!uw-beaver!ubc-cs!alberta!atha!augeas.AthabascaU.CA!ron From: ron@augeas.AthabascaU.CA (Ron Haukenfrers) Newsgroups: comp.databases Subject: Re: Embedded Sql with C Help! Message-ID: <1734@aurora.AthabascaU.CA> Date: 5 Mar 90 17:22:44 GMT References: <5154.25ee37c0@uwovax.uwo.ca> Sender: news@cs.AthabascaU.CA Lines: 109 cookson@uwovax.uwo.ca writes: >Hi out there, I'm hoping someone can give me some help. I'm >using the Ingres dbms, particularly embedded sql in the C language. >My problem is, this university does not have the companion guide for >the C language for use of embedded sql. I know their exists a >command called esqlc that converts the sql statements into C code. >What I need to know is how to compile the resulting output file. >I've typed: >esqlc -foper2.c oper.c >cc oper2.c - I get errors here - undefined command >Do i need some switches on the cc command, or should the file be including >anything? Also, are there any special language dependencies that I should >know about. In particular, on the >EXEC SQL WHENEVER SQLERROR command, how does one invoke a call to a >subroutine. It keeps giving me errors related on the opening bracket of the >parameter list for the function I want to call. >Any and all hints and advice welcome. You can post to the net, or better >yet send email to >cookson@uwovax.uwo.ca or >cookson@gaul.csd.uwo.ca >Thanks in advance for any help! >TTFN >Mike Cookson Here we use the folowing to run files through esqlc. All our embedded SQL source files have the extension .sc to distinguish them from regular .c files: esqlc -p -o.h file.sc cc $(CFLAGS) file.c rm file.c The -p option tells esqlc to include #line commands in the .c output file so the c compiler will be able to print error messages referenced to the line number in the .sc file. The -o.h tells esqlc when including files using the EXEC SQL INCLUDE command, to convert them to the standard .h extension. Make sure they originate with some other extension, we use .i I have created a set of suffix rules that can be used in a makefile to automate the compile: ------------------------------------------------------------------------------ ESQL=esqlc EFLAGS=-p -o.h # # Redefine the suffix rules to allow INGRES files to # compile automatically. This also forces make to look for a .sc # file before a .c file when checking targets # .SUFFIXES: .SUFFIXES: .o .sc .sc~ .c .c~ .y .y~ .l .l~ .s .s~ .h .h~ .sh .sh~ .f .f~ .sc: $(ESQL) $(EFLAGS) $< $(CC) -c $(CFLAGS) $(LDFLAGS) $*.c -o $@ @ rm -f $*.c .sc~: $(GET) $(GFLAGS) $< $(ESQL) $(EFLAGS) $*.sc $(CC) -c $(CFLAGS) $(LDFLAGS) $*.c -o $@ @ rm -f $*.c $*.sc .sc.a: $(ESQL) $(EFLAGS) $< $(CC) -c $(CFLAGS) $*.c $(AR) $(ARFLAGS) $@ $*.o @ rm -f $*.[co] .sc~.a: $(GET) $(GFLAGS) $< $(ESQL) $(EFLAGS) $*.sc $(CC) -c $(CFLAGS) $*.c $(AR) $(ARFLAGS) $@ $*.o @ rm -f $*.[co] $*.sc .sc.o: $(ESQL) $(EFLAGS) $< $(CC) -c $(CFLAGS) $*.c @ rm -f $*.c .sc~.o: $(GET) $(GFLAGS) $< $(ESQL) $(EFLAGS) $*.sc $(CC) -c $(CFLAGS) $*.c @ rm -f $*.c $*.sc ------------------------------------------------------------------------------ Hope that helps you out. -- Ron Haukenfrers {alberta,cbmvax,decwrl}!atha!ron Educational Computing or ron@cs.AthabascaU.CA Athabasca University