linking a pro*C program in Visual C++ 5

From: AR TATI <ar.tati_at_virgin.net>
Date: Sun, 8 Nov 1998 13:40:59 -0800
Message-ID: <727hif$375$1_at_nclient5-gui.server.virgin.net>



hello world
could somebody please tell me where I've gone wrong? I've written a very small pro*C program, which compiles fine but raises errors when I try to link it. I doing this using Visual C++5/Win95. the error reported is: error LNK2001 - unresolved external symbol sqlcex. any answers to ar.tati_at_virgin.net pelase

this is the precompliled program

/* Result Sets Interface */
#ifndef SQL_CRSR
# define SQL_CRSR

  struct sql_cursor
  {
    unsigned int curocn;
    void *ptr1;
    void *ptr2;
    unsigned long magic;
  };
  typedef struct sql_cursor sql_cursor;
  typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */

/* File name & Package Name */
struct sqlcxp
{
  unsigned short fillen;

           char filnam[47];
};
static struct sqlcxp sqlfpn =
{

    46,
    "c:\\orawin95\\pro21\\c\\samples\\sample1\\sample1.pc" };

static const unsigned long sqlctx = 909110061;

static struct sqlexd {

   unsigned long sqlvsn;
   unsigned long arrsiz;
   unsigned long iters;

   unsigned short   offset;
   unsigned short   selerr;
   unsigned short   sqlety;
   unsigned short   unused;

  const short *cud;
   unsigned char *sqlest;
  const char *stmt;
   unsigned char * *sqphsv;
   unsigned long *sqphsl;
     short * *sqpind;
   unsigned long *sqparm;
   unsigned long * *sqparc;
   unsigned char *sqhstv[4];
   unsigned long sqhstl[4];
     short *sqindv[4];
   unsigned long sqharm[4];
   unsigned long *sqharc[4];
} sqlstm = {8,4};
extern sqlcx2(/*_ unsigned long , struct sqlexd *, struct sqlcxp * _*/);
extern sqlcte(/*_ unsigned long , struct sqlexd *, struct sqlcxp * _*/);
extern sqlbuf(/*_ char * _*/);
extern sqlgs2(/*_ char * _*/);
extern sqlora(/*_ const unsigned long, void * _*/);

/* Forms Interface */

static int IAPSUCC = 0;
static int IAPFAIL = 1403;
static int IAPFTL  = 535;

extern sqliem(/*_ char *, int * _*/);

typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR; typedef struct { unsigned short len; unsigned char arr[1]; } varchar;

/* cud (compilation unit data) array */
static short sqlcud0[] =
{8,34,

2,0,0,1,0,0,27,65,0,3,3,0,1,0,1,9,0,0,1,9,0,0,1,10,0,0,
28,0,0,2,69,0,4,81,0,4,1,0,1,0,2,9,0,0,2,4,0,0,2,4,0,0,1,3,0,0,
58,0,0,3,12,0,30,109,0,0,0,0,1,0,

72,0,0,4,9,0,32,121,0,0,0,0,1,0,
};

#ifdef RCSID

static char *RCSid =

   "$Header: sample1.pc.d,v 1.4.710.1 93/11/24 13:20:04 losborne: Needtomrg_7_1 $ sample1.pc ";
#endif /* RCSID */

/* Copyright (c) 1990 by Oracle Corporation */

/* NAME
     sample1.pc
   FUNCTION
     Oracle C Precompiler sample program    RETURNS    NOTES    MODIFIED
    rahmed 08/10/95 - Cleaned up build warnings, No need for WIN_NT macro.

    syau       03/08/95 - WIN_NT: add prototype file
    tssmith    05/03/93 - Added indicator for commission
    sfaris     12/06/91 - Touch Ups
    Osborne    12/21/90 - Replacing with new version
*/
/*******************************************************************
Sample Program 1: Simple Query

This program logs on to ORACLE, prompts the user for an employee number, queries the database for the employee's name, salary, and commission, then displays the result. It continues until the user enters a 0 for the employee number.

*******************************************************************/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlproto.h"

/* EXEC SQL BEGIN DECLARE SECTION; */
 /* VARCHAR username[20]; */
struct { unsigned short len; unsigned char arr[20]; } username;  /* VARCHAR password[20]; */
struct { unsigned short len; unsigned char arr[20]; } password;  int emp_number;
 /* VARCHAR emp_name[15]; */
struct { unsigned short len; unsigned char arr[15]; } emp_name;  float salary;
 float commission;

        short commission_ind;
/* EXEC SQL END DECLARE SECTION; */  int total_queried;

/* EXEC SQL INCLUDE sqlca;
 */
/* Copyright (c) 1985,1986 by Oracle Corporation. */

/*
NAME
  SQLCA : SQL Communications Area.
FUNCTION
  Contains no code. Oracle fills in the SQLCA with status info   during the execution of a SQL stmt.
NOTES
  If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA   will be defined to have this storage class. For example:

    #define SQLCA_STORAGE_CLASS extern

  will define the SQLCA as an extern.

  If the symbol SQLCA_INIT is defined, then the SQLCA will be   statically initialized. Although this is not necessary in order   to use the SQLCA, it is a good pgming practice not to have   unitialized variables. However, some C compilers/OS's don't   allow automatic variables to be init'd in this manner. Therefore,   if you are INCLUDE'ing the SQLCA in a place where it would be   an automatic AND your C compiler/OS doesn't allow this style   of initialization, then SQLCA_INIT should be left undefined --   all others can define SQLCA_INIT if they wish.

  New rules for defining SQLCA_INIT, SQLCA_STORAGE_CLASS, and DLL in OS/2:   Users should not define SQLCA_STORAGE_CLASS if defining DLL.   SQLCA_STORAGE_CLASS is primarily used for single-threaded programs   and for internal development.

MODIFIED
  Okamura 08/15/89 - OS/2: users must define SQLMT for multi-threaded case

  Okamura    06/23/89 - OS/2: modify for multi-threaded case
  Clare      12/06/84 - Ch SQLCA to not be an extern.
  Clare      10/21/85 - Add initialization.
  Bradbury   01/05/86 - Only initialize when SQLCA_INIT set
  Clare      06/12/86 - Add SQLCA_STORAGE_CLASS option.
*/

#ifndef SQLCA
#define SQLCA 1

struct sqlca

         {
         /* ub1 */ char    sqlcaid[8];
         /* b4  */ long    sqlabc;
         /* b4  */ long    sqlcode;
         struct
           {
           /* ub2 */ unsigned short sqlerrml;
           /* ub1 */ char           sqlerrmc[70];
           } sqlerrm;
         /* ub1 */ char    sqlerrp[8];
         /* b4  */ long    sqlerrd[6];
         /* ub1 */ char    sqlwarn[8];
         /* ub1 */ char    sqlext[8];
         };


#ifdef SQLMT
extern struct sqlca *sqlcamt(); /* For multi-threaded version
*/
# define sqlca (*sqlcamt())
#else /* SQLMT */

#ifdef SQLCA_STORAGE_CLASS

  SQLCA_STORAGE_CLASS struct sqlca sqlca
# ifdef SQLCA_INIT

  • { {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, sizeof(struct sqlca), 0, { 0, {0}}, {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0} }
    # endif /* SQLCA_INIT */
    ;

#else /* SQLCA_STORAGE_CLASS */

   struct sqlca sqlca                         /* For single-threaded version
*/

# ifdef SQLCA_INIT

  • { {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, sizeof(struct sqlca), 0, { 0, {0}}, {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0} }
    # endif /* SQLCA_INIT */
    ;
    #endif /* SQLCA_STORAGE_CLASS */

#endif /* SQLMT */

/* end SQLCA */
#endif /* SQLCA */

void sqlerror(); /* handles unrecoverable errors */

void main()
{

 /* Log onto ORACLE */

 strcpy(username.arr, "SCOTT"); /* copy the username */  username.len = strlen(username.arr);
 strcpy(password.arr, "TIGER"); /* copy the password */  password.len = strlen(password.arr);

 /* EXEC SQL WHENEVER SQLERROR DO sqlerror(); */

 /* EXEC SQL CONNECT :username IDENTIFIED BY :password; */ {
 struct sqlexd sqlstm={8,3};

 sqlstm.iters = (unsigned int  )10;
 sqlstm.offset = (unsigned int  )2;
 sqlstm.cud = sqlcud0;
 sqlstm.sqlest = (unsigned char  *)&sqlca;
 sqlstm.sqlety = (unsigned short)0;
 sqlstm.sqhstv[0] = (unsigned char  *)&username;
 sqlstm.sqhstl[0] = (unsigned int  )22;
 sqlstm.sqindv[0] = (         short *)0;
 sqlstm.sqharm[0] = (unsigned int  )0;
 sqlstm.sqhstv[1] = (unsigned char  *)&password;
 sqlstm.sqhstl[1] = (unsigned int  )22;
 sqlstm.sqindv[1] = (         short *)0;
 sqlstm.sqharm[1] = (unsigned int  )0;
 sqlstm.sqphsv = sqlstm.sqhstv;
 sqlstm.sqphsl = sqlstm.sqhstl;
 sqlstm.sqpind = sqlstm.sqindv;
 sqlstm.sqparm = sqlstm.sqharm;
 sqlstm.sqparc = sqlstm.sqharc;

 sqlcex(sqlctx, &sqlstm, &sqlfpn);
 if (sqlca.sqlcode < 0) sqlerror();
}

 printf("\nConnected to ORACLE as user: %s\n", username.arr);

 /* Loop, selecting individual employee's results */

 total_queried = 0;

 while (1) {

      emp_number = 0;
      printf("\nEnter employee number (0 to quit): ");
      scanf("%d", &emp_number);
      if (emp_number == 0) break;

      /* EXEC SQL WHENEVER NOT FOUND GOTO notfound; */

      /* EXEC SQL SELECT ENAME, SAL, COMM
  INTO :emp_name,
                     :salary,
                     :commission :commission_ind
  FROM EMP
  WHERE EMPNO = :emp_number; */
{
      struct sqlexd sqlstm={8,4};
      sqlstm.stmt = "select ENAME ,SAL ,COMM into :b0,:b1,:b2:b3  from EMP
w\
here EMPNO=:b4";
      sqlstm.iters = (unsigned int  )1;
      sqlstm.offset = (unsigned int  )28;
      sqlstm.selerr = (unsigned short)1;
      sqlstm.cud = sqlcud0;
      sqlstm.sqlest = (unsigned char  *)&sqlca;
      sqlstm.sqlety = (unsigned short)0;
      sqlstm.sqhstv[0] = (unsigned char  *)&emp_name;
      sqlstm.sqhstl[0] = (unsigned int  )17;
      sqlstm.sqindv[0] = (         short *)0;
      sqlstm.sqharm[0] = (unsigned int  )0;
      sqlstm.sqhstv[1] = (unsigned char  *)&salary;
      sqlstm.sqhstl[1] = (unsigned int  )4;
      sqlstm.sqindv[1] = (         short *)0;
      sqlstm.sqharm[1] = (unsigned int  )0;
      sqlstm.sqhstv[2] = (unsigned char  *)&commission;
      sqlstm.sqhstl[2] = (unsigned int  )4;
      sqlstm.sqindv[2] = (         short *)&commission_ind;
      sqlstm.sqharm[2] = (unsigned int  )0;
      sqlstm.sqhstv[3] = (unsigned char  *)&emp_number;
      sqlstm.sqhstl[3] = (unsigned int  )4;
      sqlstm.sqindv[3] = (         short *)0;
      sqlstm.sqharm[3] = (unsigned int  )0;
      sqlstm.sqphsv = sqlstm.sqhstv;
      sqlstm.sqphsl = sqlstm.sqhstl;
      sqlstm.sqpind = sqlstm.sqindv;
      sqlstm.sqparm = sqlstm.sqharm;
      sqlstm.sqparc = sqlstm.sqharc;
      sqlcex(sqlctx, &sqlstm, &sqlfpn);
      if (sqlca.sqlcode == 1403) goto notfound;
      if (sqlca.sqlcode < 0) sqlerror();
}
      printf("\n\nEmployee\tSalary\tCommission\n");
      printf("--------\t------\t----------\n");
      emp_name.arr[emp_name.len] = '\0';
      printf("%-8s\t%6.2f\t", emp_name.arr, salary);
             if (commission_ind == -1)
                 printf("NULL\n");
             else
                 printf("%6.2f\n", commission);

      total_queried = total_queried + 1;
      continue;

 notfound:

      printf("\nNot a valid employee number - try again.\n");

 } /* end loop */

 printf("\n\nTotal number queried was %d.\n", total_queried);  printf("\nHave a good day.\n");

 /* EXEC SQL COMMIT WORK RELEASE; */
{
 struct sqlexd sqlstm={8,0};

 sqlstm.iters = (unsigned int  )1;
 sqlstm.offset = (unsigned int  )58;
 sqlstm.cud = sqlcud0;
 sqlstm.sqlest = (unsigned char  *)&sqlca;
 sqlstm.sqlety = (unsigned short)0;

 sqlcex(sqlctx, &sqlstm, &sqlfpn);
 if (sqlca.sqlcode < 0) sqlerror();
}

    /* logoff database */
 exit(0);

}

void sqlerror()
{
 /* EXEC SQL WHENEVER SQLERROR CONTINUE; */  printf("\nORACLE error detected:\n");
 printf("\n% .70s \n", sqlca.sqlerrm.sqlerrmc);

 /* EXEC SQL ROLLBACK RELEASE; */
{
 struct sqlexd sqlstm={8,0};

 sqlstm.iters = (unsigned int  )1;
 sqlstm.offset = (unsigned int  )72;
 sqlstm.cud = sqlcud0;
 sqlstm.sqlest = (unsigned char  *)&sqlca;
 sqlstm.sqlety = (unsigned short)0;

 sqlcex(sqlctx, &sqlstm, &sqlfpn);
}

 exit(1);
} Received on Sun Nov 08 1998 - 22:40:59 CET

Original text of this message