Precompiler Syntax

Embedded SQL for C and SQL Server

Embedded SQL for C and SQL Server

Precompiler Syntax

You can use either a slash (/) or a hyphen (-) to designate an nsqlprep precompiler option. For example, /DB server_name.database_name and -DB server_name.database_name are equivalent.

Syntax

nsqlprep program_file_name [/SQLACCESS | /NOSQLACCESS]
[/FLAGGER {ENTRY | NONE}] [/DB [server_name.]database_name
/PASS {login[.password] | $INTEGRATED}] [/BIND file_name]
[/MSG file_name] [/NOLOGO] [/PLAN name] [/NOLINES]
[/user_defined_option]

Arguments

program_file_name

Is the file name (without the extension) of the Embedded SQL program to precompile. The precompiler searches for the file name and the file extension .sqc. For example, if you run nsqlprep myprogrm, nsqlprep searches for Myprogrm.sqc and precompiles it if it is found.

/SQLACCESS

Specifies that nsqlprep will create stored procedures automatically for the static SQL statements in the program. You must also include /DB and /PASS to specify a direct connection to Microsoft® SQL Server™ 2000 for creating the stored procedures, or /BIND to create a bind file for later loading of the stored procedures. Note that for standard cursors, the original SELECT statement is used directly, and the stored procedures created by the /SQLACCESS option are not used.

/NOSQLACCESS

Specifies that nsqlprep will not automatically create stored procedures for static SQL statements in the program. If you also include /DB and /PASS to specify a direct connection to SQL Server, nsqlprep:

  • Issues a message.

  • Connects to SQL Server.

  • Drops stored procedures created by a previous precompile of the same program.

  • Completes the precompile without creating new stored procedures.

/FLAGGER

Specifies sending static SQL statements to the server at compile time for syntax checking. Syntax or compilation error messages generated from the server are displayed on the screen. If you specify the /FLAGGER option, you must also specify the /DB and /PASS options. You cannot use the /PLAN or /SQLACCESS options with the /FLAGGER option.

ENTRY

Specifies that static SQL statements are also checked for FIPS 127-2 SQL compliance. If the precompiler encounters SQL statements that do not conform to the specified FIPS level of support, an error message is displayed on the screen or stored in the file specified by the /MSG option. Program output is generated the same way as when you use the /NOSQLACCESS option (that is, stored procedures are not created).

NONE

Specifies that static SQL statements are not checked for FIPS 127-2 SQL compliance but are checked for correct syntax. The existence of database objects that the statements refer to is also verified.

/DB [server_name.]database_name

Specifies a database, and optionally a server running SQL Server, in which to put stored procedures for the access plan. If SQL Server is running on your local computer, you need to supply only the database_name. Whenever you use the /DB option, you must also use the /PASS option. server_name or database_name is the same server or database name in the Embedded SQL CONNECT TO statement in the program.. For more information about using /DB, see Access Plan and Bind File Options.

/PASS login[.password]

Specifies the user identifier and password for SQL Server access and stored procedure creation. Whenever you use the /PASS option, you must also use the /DB option. login and password are a user's login ID and password, or a user's login ID only. For more information about using /PASS, see Access Plan and Bind File Options.

$INTEGRATED

Forces use of Windows Authentication support for the login[.password] parameter. If Windows Authentication support is forced, any implicit run-time connection also uses Windows Authentication.

/BIND file_name

Causes creation of a bind file on precompiler execution. The extension .bnd is appended to the required file_name supplied. file_name is an MS-DOS path and file name specification. The file name should not include an extension.

The bind file is an isql script that can be used to create the desired stored procedures (it includes CREATE PROCEDURE statements). For more information about using /BIND, see Access Plan and Bind File Options.

When you create a bind file, you must use the Embedded SQL CONNECT TO statement to connect to the server. If you use this option and no stored procedure is created, the bind file is deleted.

/MSG file_name

Causes creation of a text file containing warning and error messages generated by nsqlprep processing. The .msg extension is appended to the specified file name. If nsqlprep processing does not generate any warning or error messages, the file is not generated. file_name is a Microsoft MS-DOS® path and file name specification. The file name should not include an extension.

/NOLOGO

Specifies suppression of the nsqlprep banner and the compiler banner (nsqlprep invokes the compiler).

/PLAN name

Specifies a nondefault name for an access plan. (The default name is the program_file_name without an .sql extension.)

/NOLINES

Specifies that the generated .c file be displayed for debugging, instead of the .sqc file. You must use the /NOLINES option if the .sqc source code contains C language code that appears on the same line after an EXEC SQL statement.

/user_defined_option

Is a user-defined option to be passed to the C compiler.