Re: Pro*C

From: Peter Sylvester <peters_at_mitre.org>
Date: Wed, 10 Nov 1999 07:23:43 -0500
Message-ID: <382963CF.74C27E_at_mitre.org>


[Quoted] You need to link in the appropriate libraries. See the demo makefiles that come with pro*c.
Peter

Tom Zamani wrote:
>
> Can you help me please.
> I have this Proc Program which will insert image in to database.
> when I do Proc filename.pc
> gives me the filename.c
> then
> cc filename.c
> which I get these errors
>
> /tmp/ccXQIHcz.o: In function `connect':
> /tmp/ccXQIHcz.o(.text+0x14e): undefined reference to `sqlcxt'
> /tmp/ccXQIHcz.o: In function `sqlerror':
> /tmp/ccXQIHcz.o(.text+0x211): undefined reference to `sqlcxt'
> /tmp/ccXQIHcz.o: In function `insert':
> /tmp/ccXQIHcz.o(.text+0x532): undefined reference to `sqlcxt'
> /tmp/ccXQIHcz.o(.text+0x5b4): undefined reference to `sqlcxt'
>
> Do you know why I am Getting these errors.
>
> /*****Proc Program*****/
>
> #define _HPUX_SOURCE /*This is necessary for HP platform*/
> #define _POSIX_SOURCE /*This is necessary for AIX platform*/
> #include <stdio.h>
> #include <sys/file.h>
> #include <string.h>
> #include <fcntl.h>
> EXEC SQL include sqlca;
> EXEC SQL include sqlda;
>
> #define TOTALSIZE 100000
> typedef struct
> {
> long len;
> char buf[TOTALSIZE];
> }longvarraw;
>
> typedef struct
> {
> long len;
> char *buf;
> }lvr_type;
>
> EXEC SQL begin declare section;
> EXEC SQL type longvarraw is long varraw(100000);
> EXEC SQL end declare section;
>
> void sqlerror();
>
> /********************Connect**********************/
> void connect ()
> {
> EXEC SQL begin declare section;
> char *uid="lmt0/lmt0_at_rock";
> EXEC SQL end declare section;
> EXEC SQL whenever sqlerror do sqlerror();
> EXEC SQL connect :uid;
> printf("connected\n");
> }
>
> /********************sqlerror()********************/
> void sqlerror()
> {
> EXEC SQL whenever sqlerror continue;
> printf("\nOracle Error!\n");
> printf("%s.*s\n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
> EXEC SQL rollback work release;
> exit(1);
> }
>
> /********************int
> read_file(filename,buf,bufsize)********************/
> #define LOCALSIZE 512
> int read_file(filename, buf,bufsize)
> char *filename, *buf;
> long bufsize;
> {
> char local_buffer[LOCALSIZE];
> int n;
> int total_size=0;
> int in_fd;
> in_fd=open(filename,O_RDONLY,0);
> if (in_fd=-1)
> return -1;
> while((n=read(in_fd,local_buffer,LOCALSIZE))>0)
> {
> if (total_size+n>bufsize)
> {
> close(in_fd);
> return -1;
> }
> memcpy(buf+total_size,local_buffer,n);
> total_size+=n;
> }
> close(in_fd);
> return(total_size);
> }
> /********************int insert(key,file)********************/
> int insert(key,file)
> EXEC SQL begin declare section;
> char *key,*file;
> EXEC SQL end declare section;
> {
> EXEC SQL begin declare section;
> longvarraw lvr;
> EXEC SQL end declare section;
> lvr.len=read_file(file,lvr.buf,TOTALSIZE);
> printf("length:%d\n",lvr.len);
> if(lvr.len==-1)
> exit(fprintf(stderr,"Error while reading\n"));
> connect();
> EXEC SQL whenever sqlerror do sqlerror();
> EXEC SQL insert into tmp_image values(:key,:lvr);
> EXEC SQL commit;
> printf("Inserted. \n");
> }
>
> /********************Main********************/
>
> main (argc,argv)
> int argc;
> char **argv;
> {
> char all[TOTALSIZE];
> int num_written;
>
> if (argc==2)
> {
> insert(argv[1],argv[2]);
> }
> else
> printf("Error");
> }
Received on Wed Nov 10 1999 - 13:23:43 CET

Original text of this message