Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> ORA-00932 on long column
I am having a problem converting a C program with embedded SQL from Sybase to Oracle. The history is that the column I am trying to retrieve was previously a Sybase Text field, now is an Oracle Long field.
Below are the DDL for the table and the embedded SQL that is failing in the C code. When the system reaches the point (at runtime) where it is trying to execute the SQL command 'SELECT DOCUMENT_CONTENT INTO :lcp_document_content WHERE DOCUMENT_ID = :doc_id,' the system logs the error: 'Unable to read document content (DocId = (203), sql msg = (ORA-00932: inconsistent datatypes.'
Relevant facts:
1) DOCUMENT_CONTENT is datatype LONG. 2) The system selects it into a character pointer host variable. 3) The space for the pointer is malloc'd, then memset'd to spaces, thennull terminated (when char pointers are used as host variables, according to the Programmer's Guide to the Oracle Pro*C/C++ Precompiler, the precompiler calls strlen() to determine the size of the output buffer; the buffer should not contain any embedded nulls) prior to the SELECT INTO statement.
ORA-00932 inconsistent datatypes Cause Either
Action If the cause is
different datatypes, then use consistent datatypes. For example, convert
the character field to a numeric field with the TO_NUMBER function before
adding it to the date field. Functions may not be used with long fields.
an object not intended for normal use, then do not access the restricted
object.
Is there a problem with using the long datatype in embedded SQL statements in C? Did I miss something else?
The table:
CREATE TABLE CACSG."DG_DOCUMENT_ARCHIVE"
("DOCUMENT_ID" NUMBER(9,0) NOT NULL,
"TEMPLATE_ID" NUMBER(8,0),
"DOCUMENT_GROUP_IND" CHAR(1) DEFAULT ' ' ,
"DOCUMENT_STATUS" CHAR(1) DEFAULT ' ' ,
"DOCUMENT_PRINTER" NUMBER(2,0) DEFAULT 0 ,
"DOCUMENT_COPIES" NUMBER(4,0) DEFAULT 0 ,
"DOCUMENT_CONTENT" LONG,
"BATCH_PRINT_DATE" DATE,
"REQUEST_USER" CHAR(8) DEFAULT ' ' ,
"REQUEST_STATE" CHAR(4) DEFAULT ' ' ,
"CONTENT_LENGTH" NUMBER(10,0) DEFAULT 0 );
The code:
EXEC SQL SELECT DOCUMENT_CONTENT INTO :lcp_doc_content FROM DG_DOCUMENT_ARCHIVE WHERE DOCUMENT_ID = :av_long_docid ;
Thanks,
Dave
Received on Wed Jan 22 1997 - 00:00:00 CST