SQLCODE Variable

The most important and widely used field of the SQLCA data structure is the SQLCODE variable. Each time Microsoft® SQL Server™ runs an Embedded SQL statement, it sets the value of the SQLCODE variable to indicate whether the last Embedded SQL statement completed successfully. A value of 0 indicates that the last Embedded SQL statement was successful. Values other than 0 indicate warnings or errors.

To use SQLCODE in your program, you can either declare it explicitly as long SQLCODE; or leave it undeclared and have the precompiler generate a declaration. However, the precompiler only generates a declaration in a source module that contains a main() or a WinMain() function.

The preprocessor automatically inserts the following definition in all .sqc modules, so the actual definition of SQLCODE should only occur in one module.

extern long SQLCODE;

  

If your project does not include a .sqc file that includes a main() or WinMain() function, you must explicitly declare SQLCODE in one of your modules. Explicit SQLCODE declarations can occur either inside or outside of a host variable declaration block.

See Also

Advanced Programming

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.