#include <stdlib.h>
#include <sqlca.h>
#include <stdio.h>
#include <stdarg.h>.......EXEC SQL FETCH Cu_Tb INTO :mk;//游标定义绝对正确  
if ( (sqlca.sqlcode != SQLSUCCESS) && (sqlca.sqlcode == SQLNOTFOUND) )
     return 1;
........编译提示Undeclared identifier SQLSUCCESS.
1506-045 (S) Undeclared identifier SQLNOTFOUND.请问这是为什么呢?难道oracle里面的sqlcode没有sqlnotfound?如果没有我该怎么改正呢?谢谢。

解决方案 »

  1.   

    /*
     * $Header: sqlca.h 24-apr-2003.12:50:58 mkandarp Exp $ sqlca.h 
     *//* Copyright (c) 1985, 2003, Oracle Corporation.  All rights reserved.  */
     
    /*
    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
      **************************************************************
      ***                                                        ***
      *** This file is SOSD.  Porters must change the data types ***
      *** appropriately on their platform.  See notes/pcport.doc ***
      *** for more information.                                  ***
      ***                                                        ***
      **************************************************************  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.  If the symbol SQLCA_NONE is defined, then the SQLCA variable will
      not be defined at all.  The symbol SQLCA_NONE should not be defined
      in source modules that have embedded SQL.  However, source modules
      that have no embedded SQL, but need to manipulate a sqlca struct
      passed in as a parameter, can set the SQLCA_NONE symbol to avoid
      creation of an extraneous sqlca variable.
     
    MODIFIED
        lvbcheng   07/31/98 -  long to int
        jbasu      12/12/94 -  Bug 217878: note this is an SOSD file
        losborne   08/11/92 -  No sqlca var if SQLCA_NONE macro set 
      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  */ int     sqlabc;
             /* b4  */ int     sqlcode;
             struct
               {
               /* ub2 */ unsigned short sqlerrml;
               /* ub1 */ char           sqlerrmc[70];
               } sqlerrm;
             /* ub1 */ char    sqlerrp[8];
             /* b4  */ int     sqlerrd[6];
             /* ub1 */ char    sqlwarn[8];
             /* ub1 */ char    sqlext[8];
             };#ifndef SQLCA_NONE 
    #ifdef   SQLCA_STORAGE_CLASS
    SQLCA_STORAGE_CLASS struct sqlca sqlca
    #else
             struct sqlca sqlca
    #endif
     
    #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
             ;
    #endif
     
    #endif
     
    /* end SQLCA */
    楼主说对了,果然没有
      

  2.   

    如何解决查询完毕但是没有检索到记录这种情况?
    难道和informix一样
    if(sqlca.sqlcode == 100)
        return 1;                       //没检索到记录
      

  3.   

    这是我方法:
    先定义
    #define SQLNOTFOUND 1403
    #define SQLCODE sqlca.sqlcode
    然后使用
    if (SQLCODE == SQLNOTFOUND){
        ...
    }
      

  4.   


    你的SQLSUCCESS没定义,当然会报错
    就像三楼说的,些常量需要定义一下在使用。
      

  5.   

    定义我知道  关键不我知道 在oracle中 查询完毕但是没检索到记录的时候  sqlca.sqlcode的值是多少?
    是100还是3楼说的1403?
      

  6.   

    你查一下oracle的报错码就知道了。ora-01403就是你说的查询完毕但是没检索到记录
      

  7.   

    对了,ora-01403和ora-00100的区别
    ORA-00100 no data found  
    Cause: An application made a reference to unknown or inaccessible data.  
    Action: Handle this condition within the application or make appropriate modifications to the application code.  ORA-01403 no data found  
    Cause: In a host language program, all records have been fetched. The return code from the fetch was +4, indicating that all records have been returned from the SQL query.  
    Action: Terminate processing for the SELECT statement.