Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Q: No Pro*C code works

Q: No Pro*C code works

From: Yan Zhou <yzhouy_at_yahoo.com>
Date: Thu, 05 Aug 1999 11:28:44 -0400
Message-ID: <37A9ADAB.5253C7EB@yahoo.com>

Hi there,

  I am new on Pro*C, please forgive me if I am asking stupid questions. Basically I am trying to run Pro*C to retrieve BLOB data from an Oracle8i table.
The code and the error message from Pro*C/C++ compiler are enclosed. My problem
is that I could not get any Pro*C code pre-compiled successfully, even with
Oracle's demo *.PC file. I activiate the Pro*C/C++ compiler and load up a demo
*.PC file from Oracle, the compiler keeps complaining (see the attached error message).

 I must have missed something like environment setting, options, etc. But, I
could not find any documents to help me with that. What does it take to run Pro*C/C++ compiler ?

 Any hint is greatly appreciated. I am running my code from a NT4.0 workstation
which has DB access to an Oracle8i server installed on NT4.0 server.

 By the way, I wish I could use plain Visual C++ (MFC) code to access LOB
data in Oracle8i. But I have not had success yet. If any of you knows how to
do that, please let me know.

 Thanks.

                        Yan
                        yzhou_at_lexmark.com

/*
 Table definition:

 TABLE: DEMO

 COLUMNS: ID       NUMBER
          THEBLOB  BLOB

 There is a record with ID=2 and THEBLOB has the data of an image file */

/* This code reads the entire contents of a BLOB piecewise into a

   buffer using a standard polling method, processing each buffer piece    after every READ operation until the entire BLOB has been read: */

#include <oci.h>
#include <stdio.h>
#include <sqlca.h>

void Sample_Error()
{
  EXEC SQL WHENEVER SQLERROR CONTINUE;
  printf("%.*s\n", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);   EXEC SQL ROLLBACK WORK RELEASE;
  exit(1);
}

#define BufferLength 3000

void checkOutLOB_proc()
{
  OCIBlobLocator *Lob_loc;
  int Amount;
  int GivenID;
  VARCHAR Buffer[BufferLength];

  EXEC SQL WHENEVER SQLERROR DO Sample_Error();   EXEC SQL ALLOCATE :Lob_loc;

/* Use Dynamic SQL to retrieve the LOB: */
  EXEC SQL PREPARE S FROM
    'SELECT THEBLOB \

       FROM DEMO \
             WHERE ID = :GivenID';

  EXEC SQL DECLARE C CURSOR FOR S;
  GivenID = 2;
  EXEC SQL OPEN C USING :GivenID;
  EXEC SQL FETCH C INTO :Lob_loc;
  EXEC SQL CLOSE C;
/* Open the LOB: */

  EXEC SQL LOB OPEN :Lob_loc READ ONLY;

/* Setting Amount = 0 will initiate the polling method: */
  Amount = 0;

/* Set the maximum size of the Buffer: */
  Buffer.len = BufferLength;
  EXEC SQL WHENEVER NOT FOUND DO break;   while (TRUE)
    {

      /* Read a piece of the LOB into the Buffer: */
      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;
      printf("Checkout %d characters\n", Buffer.len);
    }
  printf("Checkout %d characters\n", Amount);

/* Closing the LOB is mandatory if you have opened it: */
  EXEC SQL LOB CLOSE :Lob_loc;
  EXEC SQL FREE :Lob_loc;
}

void main()
{
/* declare needed host variables */

char  username[10]  = "system";
char  password[10]  = "manager";
char  db_string[20] = "TO8I";

/* give the database connection a unique name */ EXEC SQL DECLARE DB_NAME DATABASE; /* connect to the non-default database */ EXEC SQL CONNECT :username IDENTIFIED BY :password

   AT DB_NAME USING :db_string;

  checkOutLOB_proc();

  EXEC SQL ROLLBACK WORK RELEASE;
}

++: Release 8.1.5.0.0 - Production on Thu Aug 5 11:23:35 1999

(c) Copyright 1999 Oracle Corporation. All rights reserved.

System default option values taken from: D:\ORA8I\precomp\admin\pcscfg.cfg

Semantic error at line 39, column 22, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL ALLOCATE :Lob_loc;

.....................1

PCC-S-02322, found undefined identifier Semantic error at line 39, column 12, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL ALLOCATE :Lob_loc;
...........1
PCC-S-02319, expression type does not match usage Semantic error at line 39, column 3, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL ALLOCATE :Lob_loc;
..1
PCC-S-02336, host variable expression has invalid type Semantic error at line 48, column 26, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL OPEN C USING :GivenID;
.........................1

PCC-S-02322, found undefined identifier Semantic error at line 49, column 26, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL FETCH C INTO :Lob_loc;
.........................1

PCC-S-02322, found undefined identifier Semantic error at line 53, column 22, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL LOB OPEN :Lob_loc READ ONLY;
.....................1

PCC-S-02322, found undefined identifier Semantic error at line 53, column 22, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL LOB OPEN :Lob_loc READ ONLY;
.....................1

PCC-S-02336, host variable expression has invalid type Semantic error at line 53, column 22, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL LOB OPEN :Lob_loc READ ONLY;
.....................1

PCC-S-02430, Expecting an expression of some arbitrary LOB type Semantic error at line 64, column 26, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

.........................1

PCC-S-02322, found undefined identifier Semantic error at line 64, column 26, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

.........................1

PCC-S-02336, host variable expression has invalid type Semantic error at line 64, column 26, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

.........................1

PCC-S-02437, Expecting an expression having binary integral type Semantic error at line 64, column 39, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

......................................1
PCC-S-02322, found undefined identifier Semantic error at line 64, column 39, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

......................................1
PCC-S-02336, host variable expression has invalid type Semantic error at line 64, column 39, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

......................................1
PCC-S-02430, Expecting an expression of some arbitrary LOB type Semantic error at line 64, column 53, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

....................................................1
PCC-S-02322, found undefined identifier Semantic error at line 64, column 53, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

....................................................1
PCC-S-02336, host variable expression has invalid type Semantic error at line 64, column 53, file D:\TestCenter\BlobProC\BlobRead.pc:

      EXEC SQL LOB READ :Amount FROM :Lob_loc INTO :Buffer;

....................................................1
PCC-S-02428, Buffer type is incompatible with LOB type Semantic error at line 70, column 23, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL LOB CLOSE :Lob_loc;
......................1

PCC-S-02322, found undefined identifier Semantic error at line 70, column 23, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL LOB CLOSE :Lob_loc;
......................1

PCC-S-02336, host variable expression has invalid type Semantic error at line 70, column 23, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL LOB CLOSE :Lob_loc;
......................1

PCC-S-02430, Expecting an expression of some arbitrary LOB type Semantic error at line 71, column 18, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL FREE :Lob_loc;
.................1

PCC-S-02322, found undefined identifier Semantic error at line 71, column 12, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL FREE :Lob_loc;
...........1
PCC-S-02319, expression type does not match usage Semantic error at line 71, column 12, file D:\TestCenter\BlobProC\BlobRead.pc:
  EXEC SQL FREE :Lob_loc;
...........1
PCC-S-02336, host variable expression has invalid type Semantic error at line 85, column 19, file D:\TestCenter\BlobProC\BlobRead.pc:
EXEC SQL CONNECT :username IDENTIFIED BY :password
..................1

PCC-S-02322, found undefined identifier Semantic error at line 85, column 43, file D:\TestCenter\BlobProC\BlobRead.pc:
EXEC SQL CONNECT :username IDENTIFIED BY :password
..........................................1
PCC-S-02322, found undefined identifier Semantic error at line 86, column 22, file D:\TestCenter\BlobProC\BlobRead.pc:

   AT DB_NAME USING :db_string;

.....................1

PCC-S-02322, found undefined identifier Received on Thu Aug 05 1999 - 10:28:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US